Schema Composition

JSON Schema lets you combine multiple subschemas on a single field using allOf, anyOf, oneOf, and not.

allOf (AND)

The value must be valid against all of the given subschemas.

Activation Conditions

  • allOf keyword present — the field still renders with its own type's normal editor; every subschema is validated together.

Example

{
  "type": "string",
  "title": "Username (allOf)",
  "allOf": [
    {
      "minLength": 3
    },
    {
      "pattern": "^[a-z0-9_]+$"
    }
  ]
}

anyOf (OR)

The value must be valid against any (one or more) of the given subschemas.

Activation Conditions

  • anyOf keyword present — jedison shows a switcher to pick which candidate schema to fill in as.

Example

{
  "type": "number",
  "title": "Number (anyOf)",
  "anyOf": [
    {
      "type": "number",
      "multipleOf": 3
    },
    {
      "type": "number",
      "multipleOf": 5
    }
  ]
}

oneOf (XOR)

The value must be valid against exactly one of the given subschemas — matching more than one is invalid too.

Activation Conditions

  • oneOf keyword present — uses the same switcher UI as anyOf.

anyOf vs. oneOf

Try 15 in both this example and the anyOf example above: 15 is a multiple of both 3 and 5, so it's valid for anyOf but invalid for oneOf.

Example

{
  "type": "number",
  "title": "Number (oneOf)",
  "oneOf": [
    {
      "type": "number",
      "multipleOf": 3
    },
    {
      "type": "number",
      "multipleOf": 5
    }
  ]
}

not (NOT)

The value must not be valid against the given subschema.

Activation Conditions

  • not keyword present — adds a validation rule on top of the field's normal editor; it doesn't change which editor is used.

Example

{
  "type": "string",
  "title": "Username (not)",
  "not": {
    "const": "admin"
  }
}