Liking cljdoc? Tell your friends :D

d-core.core.schema

Schema helpers for D-core.

This module is intentionally small:

  • Applies strictness (:strict/:lax) to Malli map schemas (:closed true/false)
  • Validates values and throws typed, non-retriable exceptions for poison handling
  • Provides temporal schema constructors (temporal) that make the expected date/time domain and wire dialect an explicit, declarative per-field choice (roadmap 02, B6).
Schema helpers for D-core.

This module is intentionally small:
- Applies strictness (:strict/:lax) to Malli map schemas (:closed true/false)
- Validates values and throws typed, non-retriable exceptions for poison handling
- Provides temporal schema constructors (`temporal`) that make the expected
  date/time domain *and* wire dialect an explicit, declarative per-field choice
  (roadmap 02, B6).
raw docstring

apply-strictnessclj

(apply-strictness schema strictness)

Applies :strict/:lax strictness to all Malli :map schemas by setting :closed.

Applies :strict/:lax strictness to all Malli :map schemas by setting :closed.
raw docstring

explainclj

(explain schema value)

Returns a compact explain payload safe to include in ex-data / DLQ. Includes both raw explain and humanized errors.

Returns a compact explain payload safe to include in ex-data / DLQ.
Includes both raw explain and humanized errors.
raw docstring

json-schemaclj

(json-schema schema)

Returns the JSON Schema fragment for a temporal schema, as consumed by OpenAPI generators. Keeps {} out of the generated spec.

Returns the JSON Schema fragment for a temporal schema, as consumed by OpenAPI
generators. Keeps `{}` out of the generated spec.
raw docstring

openapi-schemaclj

(openapi-schema schema)

Alias for json-schema — the OpenAPI definition emitted for a temporal schema.

Alias for `json-schema` — the OpenAPI definition emitted for a temporal schema.
raw docstring

temporalclj

(temporal domain)
(temporal domain dialect)

Declares the expected date/time domain (and optionally its wire dialect) for a field.

(temporal :instant)               ;; defaults to the platform dialect, :epoch-ms
(temporal :instant :rfc3339)      ;; explicit encoding for interop
(temporal :local-date)            ;; a civil date that never becomes an instant

Validates internal java.time values: encoding is the boundary codec's job, not the schema's. Returns a malli schema, so it composes inside :map schemas and is enforced by reitit's request coercion and rendered into OpenAPI automatically.

Throws at declaration time when the pairing is impossible — a boundary-only domain, an unknown domain, or a dialect that cannot carry the domain (§4.1).

Declares the expected date/time domain (and optionally its wire dialect) for a
field.

```clojure
(temporal :instant)               ;; defaults to the platform dialect, :epoch-ms
(temporal :instant :rfc3339)      ;; explicit encoding for interop
(temporal :local-date)            ;; a civil date that never becomes an instant
```

Validates internal `java.time` values: encoding is the boundary codec's job, not
the schema's. Returns a malli schema, so it composes inside `:map` schemas and is
enforced by reitit's request coercion and rendered into OpenAPI automatically.

Throws at *declaration* time when the pairing is impossible — a boundary-only
domain, an unknown domain, or a dialect that cannot carry the domain (§4.1).
raw docstring

temporal-dialectclj

(temporal-dialect schema)

Returns the declared wire dialect of a schema produced by temporal.

Returns the declared wire dialect of a schema produced by `temporal`.
raw docstring

temporal-domainclj

(temporal-domain schema)

Returns the declared temporal domain of a schema produced by temporal.

Returns the declared temporal domain of a schema produced by `temporal`.
raw docstring

valid?clj

(valid? schema value)

Returns true when value satisfies schema. A thin, total counterpart to validate! for callers that want a boolean rather than an exception.

Returns true when `value` satisfies `schema`. A thin, total counterpart to
`validate!` for callers that want a boolean rather than an exception.
raw docstring

validate!clj

(validate! schema value)
(validate! schema value {:keys [schema-id strictness]})

Validates value against schema (optionally applying strictness).

On failure, throws ex-info with:

  • :failure/type :schema-invalid
  • :retriable? false
  • :schema/id (optional)
  • :schema/explain (compact explain payload)
Validates `value` against `schema` (optionally applying `strictness`).

On failure, throws ex-info with:
- :failure/type :schema-invalid
- :retriable? false
- :schema/id (optional)
- :schema/explain (compact explain payload)
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close