oferei / json-gate

A friendly, fast JSON schema validator
MIT License
100 stars 16 forks source link

Union type not supported at highest level #18

Closed feugy closed 11 years ago

feugy commented 11 years ago

When creating a schema with an union type, an error is thrown:

var schema = createSchema({
  type: ['array', 'null'],
  items: {
    type: 'number'
  }
});

produces:

Schema: 'type' attribute is an array when it should be a string
    at throwInvalidType (..../json-gate/lib/valid-schema.js:10:8)
    at assertType (..../json-gate/lib/valid-schema.js:16:4)
    at module.exports (..../json-gate/lib/valid-schema.js:281:2)
    at new Schema (..../json-gate/lib/json-gate.js:6:2)
oferei commented 11 years ago

thanks for the heads up! I'll look into as soon as my laptop is fixed... ;)