基本示例驗證模式

{
    "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"
}