The home of JSON Schema validation right in your browser 🚧 Alpha 🚧 draft-7 only
Valid JSON:
xxxxxxxxxx
{
"$schema": "http://json-schema.org/draft-07/schema",
"type": "object",
"definitions": {
"is_student": {
"properties": {
"contact_type": {
"contains": {
"const": "Student"
}
}
}
},
"is_primay_contact": {
"properties": {
"contact_type": {
"contains": {
"const": "Primary Contact"
}
}
}
}
},
"required": ["contact_type"],
"properties": {
"contact_type": {
"type": "array",
"items": {
"enum": ["Primary Contact", "Student"]
}
},
"phone": true,
"first_name": true
},
"additionalProperties": false,
"allOf": [
{
"if": { "$ref": "#/definitions/is_student" },
"then": { "required": ["first_name"] }
},
{
"if": { "$ref": "#/definitions/is_primay_contact" },
"then": { "required": ["phone"] }
},
{
"if": {
"allOf": [
{ "$ref": "#/definitions/is_student" },
{ "$ref": "#/definitions/is_primay_contact" }
]
},
"then": {
"required": ["phone", "first_name"]
},
"else": {
"oneOf": [
{
"required": ["phone"]
},
{
"required": ["first_name"]
}
]
}
}
]
}
Valid JSON:
xxxxxxxxxx
{
"contact_type":["Primary Contact", "Student"],
"phone":"something",
"first_name":"something"
}
jsonschema.dev@relequestual Thanks to Sponsors: