Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to describe an array of specified objects? #50

Open
muturgan opened this issue Sep 10, 2021 · 1 comment
Open

How to describe an array of specified objects? #50

muturgan opened this issue Sep 10, 2021 · 1 comment

Comments

@muturgan
Copy link

I have tried to validate a return-value at the "api.example.countries" method from the example reposytory.
It returns something like this:

{
  result: "success",
  data: [{
    countryId: "1",
    name: "Soviet Union"
  }]
}

I have modified this method:

({
  access: 'public',

  returns: {
    result: 'string',
    data: {
      type: 'array',
      value: {
        countryId: 'string',
        name: 'string',
      },
    },
  },

  method: .....
});

And now I see an error in the browser console on a method call:
Invalid result type: Field "data" expected to be array of [object Object].
Of cause I can define the data as

data: {
  type: 'array',
  value: 'object'
}

But it is not strict.

So how I can define a schema in a right way?

@georgolden
Copy link
Member

There is no such feature now, so I will give an implementation very soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants