我有下一个模式:
export const User = {
type: 'object',
properties: {
id: {
type: 'number',
minimum: 1,
},
firstName: {
type: 'string',
},
lastName: {
type: 'string',
},
email: {
type: 'string',
format: 'email',
},
},
}
和Ajv实例:
const ajv = new Ajv({ allErrors: true, coerceTypes: true })
但是当我传递数字Ajv响应时,它以字符串形式出现:
//ok
{
"firstName": 55
}
当我将coerceTypes
设置为false
时,验证失败,应该是:
//error
{
"firstName": 55
}