Contracts
Contracts copied to clipboard
How to describe an array of specified objects?
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?
There is no such feature now, so I will give an implementation very soon.