Schema helpers for D-core.
This module provides:
validate!, valid?) throwing typed, non-retriable exceptionstemporal) and WIRE <-> SYSTEM coercion
(coerce!, coerce, ->wire!, ->wire, temporal-transformer) (roadmap 02, B6).Schema helpers for D-core. This module provides: - Strictness (:strict/:lax) application to Malli map schemas (:closed true/false) - Validation (`validate!`, `valid?`) throwing typed, non-retriable exceptions - Temporal schema constructors (`temporal`) and WIRE <-> SYSTEM coercion (`coerce!`, `coerce`, `->wire!`, `->wire`, `temporal-transformer`) (roadmap 02, B6).
(->wire schema value)(->wire schema value opts)Total SYSTEM -> WIRE encoding: returns {:ok wire-value} or {:error ...}.
Total SYSTEM -> WIRE encoding: returns `{:ok wire-value}` or `{:error ...}`.
(->wire! schema value)(->wire! schema value {:keys [strictness] :as opts})Strict SYSTEM -> WIRE encoding: validates value against schema and encodes
all (schema/temporal ...) fields into their declared wire dialects.
Strict SYSTEM -> WIRE encoding: validates `value` against `schema` and encodes all `(schema/temporal ...)` fields into their declared wire dialects.
(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.
(coerce schema wire-value)(coerce schema wire-value {:keys [schema-id strictness]})Total WIRE -> SYSTEM coercion: decodes temporal fields in wire-value according
to schema and validates the resulting map.
Returns {:ok coerced-value} or {:error {:failure/type :schema-invalid ...}}.
Total WIRE -> SYSTEM coercion: decodes temporal fields in `wire-value` according
to `schema` and validates the resulting map.
Returns `{:ok coerced-value}` or `{:error {:failure/type :schema-invalid ...}}`.(coerce! schema wire-value)(coerce! schema wire-value opts)Strict WIRE -> SYSTEM coercion: decodes temporal fields in wire-value according
to schema and validates the result.
Throws non-retriable :schema-invalid ex-info (with :temporal/errors diagnostics) on failure.
Strict WIRE -> SYSTEM coercion: decodes temporal fields in `wire-value` according to `schema` and validates the result. Throws non-retriable `:schema-invalid` ex-info (with `:temporal/errors` diagnostics) on failure.
(explain schema value)Returns a compact explain payload safe to include in ex-data / DLQ.
Includes raw explain, humanized errors, and rich :temporal/errors diagnostics
(powered by d-core.temporal/explain) when any temporal field fails.
Returns a compact explain payload safe to include in ex-data / DLQ. Includes raw explain, humanized errors, and rich `:temporal/errors` diagnostics (powered by `d-core.temporal/explain`) when any temporal field fails.
(json-schema schema)Returns the JSON Schema fragment for a schema, as consumed by OpenAPI generators.
Returns the JSON Schema fragment for a schema, as consumed by OpenAPI generators.
(openapi-schema schema)Alias for json-schema — the OpenAPI definition emitted for a schema.
Alias for `json-schema` — the OpenAPI definition emitted for a schema.
(temporal domain)(temporal domain dialect-or-opts)Declares the expected date/time domain and wire dialect (or ingress options map) for a field.
(temporal :instant) ;; defaults to :epoch-ms
(temporal :instant :rfc3339) ;; explicit RFC-3339 string
(temporal :instant {:dialect :iso-local :zone "UTC"}) ;; foreign zone-less string -> UTC Instant
(temporal :duration :seconds) ;; e.g. OAuth expires_in: 3600 -> Duration
(temporal :local-date) ;; ISO civil date -> LocalDate
Declares the expected date/time domain and wire dialect (or ingress options map)
for a field.
```clojure
(temporal :instant) ;; defaults to :epoch-ms
(temporal :instant :rfc3339) ;; explicit RFC-3339 string
(temporal :instant {:dialect :iso-local :zone "UTC"}) ;; foreign zone-less string -> UTC Instant
(temporal :duration :seconds) ;; e.g. OAuth expires_in: 3600 -> Duration
(temporal :local-date) ;; ISO civil date -> LocalDate
```(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`.
(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`.
(temporal-opts schema)Returns the normalized dialect options map of a schema produced by temporal.
Returns the normalized dialect options map of a schema produced by `temporal`.
(temporal-transformer)Returns a Malli transformer that decodes and encodes (schema/temporal ...) fields
between wire representations and in-memory java.time objects.
Returns a Malli transformer that decodes and encodes `(schema/temporal ...)` fields between wire representations and in-memory `java.time` objects.
(valid? schema value)Returns true when value satisfies schema.
Returns true when `value` satisfies `schema`.
(validate! schema value)(validate! schema value {:keys [schema-id strictness]})Validates value against schema (optionally applying strictness).
On failure, throws ex-info with:
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)
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |