Validate JSON data with schemas, types, required fields, formats, composition, and API contracts.
Lessons
Require data to match exactly one subschema.
oneOf is easiest to learn by reading the example, changing it, and observing the result.
{
"oneOf": [
{
"properties": { "type": { "const": "card" }, "last4": { "type": "string" } },
"required": ["type", "last4"]
},
{
"properties": { "type": { "const": "paypal" }, "email": { "type": "string" } },
"required": ["type", "email"]
}
]
}Practice the oneOf example in a small scratch file, then explain what changed and why.