我正在使用 Ajv 来验证我的 JSON 数据。我无法找到将空字符串验证为键值的方法。我尝试使用模式,但它没有抛出适当的消息。
这是我的架构
{
"type": "object",
"properties": {
"user_name": { "type": "string" , "minLength": 1},
"user_email": { "type": "string" , "minLength": 1},
"user_contact": { "type": "string" , "minLength": 1}
},
"required": [ "user_name", 'user_email', 'user_contact']
}
我正在使用 minLength 来检查该值是否应包含至少一个字符。但它也允许空白空间。