Liking cljdoc? Tell your friends :D

d-core.core.schema

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).
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).
raw docstring

->wireclj

(->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 ...}`.
raw docstring

->wire!clj

(->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.
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

coerceclj

(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 ...}}`.
raw docstring

coerce!clj

(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.
raw docstring

explainclj

(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.
raw docstring

json-schemaclj

(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.
raw docstring

openapi-schemaclj

(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.
raw docstring

temporalclj

(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
```
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

temporal-optsclj

(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`.
raw docstring

temporal-transformerclj

(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.
raw docstring

valid?clj

(valid? schema value)

Returns true when value satisfies schema.

Returns true when `value` satisfies `schema`.
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