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?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.