Extends · closed
| value The one value this schema accepts: a string, integer, boolean, or null. | ||
| description What this value means, for people and for the editors that offer it. | optional |
Literal: a schema that accepts exactly one value. You write it as the value itself ("Change", 1, true, null), or as {value, description} when the value needs an explanation. Only a string, integer, boolean or null can be a literal. The schema language covers literals with the rest of the vocabulary.
A literal schema accepts exactly one value. Most literals are written as the value itself, such as "draft", 1, true or null, and need no variant at all: a bare string, integer, boolean or null is a schema. This variant is the long form, {value, description}, for a literal that needs an explanation, such as one choice among several in a union.
A fixed set of choices is a union of literals: {"anyOf": ["draft", {"value": "published", "description": "Visible to everyone"}, "archived"]}. The editors show such a union as a dropdown, with each description beside its option. A field pinned to one value is that literal. The type tag of every signed blob and the key of every Seed API request work this way: "type": {"value": "Change", "required": true}.
A literal can only be a value: a string, an integer, a boolean or null. A map literal would look exactly like a schema, and floats do not compare reliably.
See also
Union schema: a fixed set of choices is a union of literals.
Scalar schema: a scalar kind with constraints, where a literal pins one value.
Kind: the value types a literal can come from.
The schema language: the full vocabulary.
Blob: every signed blob pins its type tag with a literal.
Do you like what you are reading? Subscribe to receive updates.
Unsubscribe anytime