【发布时间】:2015-02-02 17:44:57
【问题描述】:
我有架构,
'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应该是整数,最小值=0;
但是,然后我验证有效载荷 {driversNeeded: null, date: '2015-11-11'} 它认为它是有效的。
除了null 之外的我只有在我在类型中明确说["integer", "null"] 时才能被接受。
如何防止null 被接受为整数?
【问题讨论】:
-
仅供参考,您在架构中也拼错了“minimum”。
标签: javascript json node.js jsonschema