Validate JSON data with schemas, types, required fields, formats, composition, and API contracts.
Lessons
Constrain numbers with minimum, maximum, and multipleOf.
Validating Numbers is easiest to learn by reading the example, changing it, and observing the result.
{
"type": "object",
"properties": {
"rating": {
"type": "number",
"minimum": 0,
"maximum": 5
},
"discount": {
"type": "number",
"exclusiveMinimum": 0,
"exclusiveMaximum": 100
}
}
}Practice the Validating Numbers example in a small scratch file, then explain what changed and why.