JSON Schema examples
This page provides five JSON Schema validation examples, illustrating use cases such as conditional and alternative field requirements (anyOf and oneOf), schema reuse with references, supporting multiple valid formats for a field, and combining $ref with other validation rules. These examples demonstrate validation patterns and logic that go beyond the standard UI.
See:
JSON Schema reference - For details about formal definitions, interoperability considerations, keyword behaviors, and advanced topics.
JSON Schema keywords and types - For quick-reference tables and practical guidance on JSON Schema keywords and formats.
Examples
Example 1: Conditional field requirement with anyOf and oneOf
Example 2: Schema reuse with $ref and $id - recommended
Example 3: Schema reuse with $ref (definitions) - legacy
Example 4: Multiple formats allowed with anyOf
Example 5: Combining $ref with other rules (double schema with $ref)
Reference links
For more details on using JSON Schema, see JSON Schema reference.