flatiron / revalidator

A cross-browser / node.js validator powered by JSON Schema
http://github.com/flatiron/revalidator
Apache License 2.0
589 stars 82 forks source link

Array validation #108

Open Diokuz opened 9 years ago

Diokuz commented 9 years ago

I have an array of contacts:

var contacts = [{
    type: 'email',
    value: 'x@x.x'
}, {
    type: 'phone',
    value: '+8 9123 23213123'
}]

Can you please give me an example of schema for this case?

marcysutton commented 8 years ago

+1 to this. I need to validate that an object contains an array and this doesn't work for that use case at all.

4kochi commented 7 years ago

I am not sure if revalidator can handle array as root item. But I know that the lib https://github.com/litixsoft/lx-valid can do it. Here is the schema:

const schema = {
  type: 'array',
  items: {
    type: 'object',
    properties: {
      type: {
        type: 'string'
      },
      value: {
        type: 'string'
      }
    }
  }
};
brennick commented 6 years ago

Was this ever solved for revalidator library?