metarhia/metaschema

How to describe an array of specified objects?

Closed this issue · 2 comments

Well, after a private call, converting this question to an issue.

I have tried to validate this data structure as a method's return value

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

via metaschema.
My method's schema is:

({
  access: 'public',

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

  method: .....
});

But a return value from the first code snippet leads to an error:
Invalid result type: Field "data" expected to be array of [object Object].

Looks like this nested validation feature does not implemented yet.