基本示例验证模式
{
"title": "Person",
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"description": "Age in years",
"type": "integer",
"minimum": 0
}
},
"required": ["firstName", "lastName"]
}
结果
// Valid
{
"firstName": "Jason",
"lastName": "Voorhees"
}
// Valid
{
"firstName": "Jason",
"lastName": "Voorhees",
"age": 47
}
// Invalid - no lastName
{
"firstName": "Jason",
"age": 47
}
// Invalid - age is not integer
{
"firstName": "Jason",
"lastName": "Voorhees",
"age": "47"
}