oneOf - Type Selection
TheoneOf keyword allows users to choose between different schema alternatives. This is useful for polymorphic data.
- Schema
- UI Schema
- Data
address and user schemas.
anyOf - Multiple Valid Types
TheanyOf keyword is similar to oneOf but allows data to match multiple schemas simultaneously.
- Schema
- UI Schema
- Data
allOf - Schema Composition
TheallOf keyword combines multiple schemas, useful for extending base schemas with additional properties.
- Schema
- UI Schema
- Data
address schema plus the additional type field.
Rules - Conditional Rendering
Rules enable dynamic form behavior based on data values. Use rules to show, hide, enable, or disable form elements.- Schema
- UI Schema
- Data
Rule Effects
- SHOW: Shows the element when condition is true
- HIDE: Hides the element when condition is true
- ENABLE: Enables the element when condition is true
- DISABLE: Disables the element when condition is true
Rule Conditions
Conditions use JSON Schema to test data values:Schema References
Use$ref to reuse schema definitions and keep your schemas DRY:
Best Practices
- Use oneOf when the user must choose exactly one type
- Use anyOf when multiple schemas can apply simultaneously
- Use allOf to extend base schemas with additional properties
- Use rules for dynamic form behavior instead of conditional schemas when possible
- Keep schema definitions reusable with
$ref - Use
additionalProperties: falsewith oneOf/anyOf to help JSON Forms distinguish between alternatives - Provide clear titles in oneOf/anyOf definitions for better user experience
Next Steps
- Learn more about Rules for advanced conditional logic
- Explore Custom Renderers to handle specialized schema patterns
- See Validation for custom validation logic