Skip to main content

schema.validator

Jump to function (9)

schema.validator/map-entry-optional?#

(map-entry-optional? entry)

Returns true when a [:map ...] entry is declared with {:optional true}.

schema.validator/map-entry-options#

(map-entry-options entry)

Options map for a [:map ...] entry [key opts? schema]. Returns an empty map when the entry has no options position.

schema.validator/map-entry-schema#

(map-entry-schema entry)

Inner schema of a [:map ...] entry, skipping the options map when present.

schema.validator/resolve-or-default#

(resolve-or-default head f default)

Like resolve-or-throw, but returns default when head is not registered instead of throwing. Used by coerce where unknown heads are intentionally passed through unchanged for downstream validation to flag.

schema.validator/resolve-or-throw#

(resolve-or-throw label head f)

Resolves an unknown head by looking it up in the registry. When head names a registered schema, invokes f with the registered schema; otherwise throws an InvalidArgumentException mentioning label (e.g. "unknown schema kind" or "no generator for schema kind").

Every head-dispatching caller uses this so the error shape is consistent across validator/explainer/coercer/generator.

schema.validator/schema-args#

(schema-args schema)

Returns the positional arguments of schema (children past the head and optional options map).

schema.validator/schema-head#

(schema-head schema)

Returns the head (kind keyword) of schema. Keyword schemas are their own head; vector schemas use their first element.

schema.validator/schema-options#

(schema-options schema)

Returns the options map of schema or {} if none.

schema.validator/valid?#

(valid? schema value)

Returns true if value conforms to schema, otherwise false.

Example:

(valid? :int 1) ; => true