Skip to content

Instantly share code, notes, and snippets.

@boseabhishek
Created September 18, 2024 11:40
Show Gist options
  • Save boseabhishek/f1cf5396d39e6c028ac3420830201fbf to your computer and use it in GitHub Desktop.
Save boseabhishek/f1cf5396d39e6c028ac3420830201fbf to your computer and use it in GitHub Desktop.
refs, defs, schemas
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Person",
"type": "object",
"properties": {
"contact": {
"anyOf": [
{ "$ref": "#/$defs/emailContact" },
{ "$ref": "#/$defs/phoneContact" }
]
}
},
"required": ["contact"],
"$defs": {
"emailContact": {
"type": "object",
"properties": {
"email": { "type": "string", "format": "email" }
},
"required": ["email"]
},
"phoneContact": {
"type": "object",
"properties": {
"phone": { "type": "string", "pattern": "^[0-9]{10}$" }
},
"required": ["phone"]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment