Skip to content

A null config value is present, and its schema decides whether it is acceptable

The rule

Normative: this is the rule
  1. A config value of null is present, with no value.
  2. It MUST satisfy a required key.
  3. It MUST be validated against the key's schema as JSON Schema validates it: it MUST fail type unless the type admits null, and MUST fail enum unless the enumeration lists null.
  4. Constraints that apply only to strings, numbers, arrays or objects, such as bounds and pattern, do not apply to a null.

What it means

Presence and value are judged separately, as JSON Schema judges them. A required key set to null is present, so it satisfies the requirement. Its value is then checked like any other: null is a type of its own, so it fails a key whose type does not admit it, and it fails an enum that does not list it. Bounds and pattern describe numbers and strings, and say nothing about a null.

Example

A required key whose schema is { "type": "string", "minLength": 5 }:

A required key set to nullrefused
{"url": null}

The requirement is met, but type refuses the value. With { "type": ["string", "null"], "minLength": 5 } the same config is accepted.

Why

Recorded under OPEN-25, OPEN-26.

Rule identifiers are permanent and are never renumbered. Each implementation publishes its own standing against these rules; this specification does not.spec 1.0 · R6.i · changed in spec 1.0