Reputation: 19841
I have schema,
'demand': {
description: 'demand model',
type: 'object',
additionalProperties: false,
properties: {
'_id': {
type: 'string'
},
'driversNeeded': {
required: true,
type: 'integer',
minumum: 0
},
'date': {
required: true,
type: 'string',
pattern: /^\d{4}-\d{2}-\d{2}$/
}
}
}
driversNeeded
is supposed to be integer, with minimum value = 0;
But, then I validate payload {driversNeeded: null, date: '2015-11-11'}
it treat it as valid.
I except null
could be only accepted if I explicitly say ["integer", "null"]
in type.
How can I prevent null
to be accepted as integer?
Upvotes: 1
Views: 347
Reputation: 12901
That schema works for me, as it should (I get "Invalid type: null (expected integer)").
My best guess is that the issue might be in the larger document structure, meaning that the data isn't actually being tested against the schema you expect.
Upvotes: 1