Liking cljdoc? Tell your friends :D

dev.skivi.validation.interface

Job payload validation interface supporting malli schemas, clojure.spec specs, and composite chains of validators.

Typical usage:

;; From config (malli schemas or clojure.spec keywords in [:schema :job-schemas]) (def v (create-validator config))

;; Directly (def v (malli-validator {:send-email [:map [:to :string] [:subject :string]]}))

;; Validate (validate-payload v :send-email {:to "x@y.com" :subject "Hi"})

To enable malli instrumentation of this namespace:

(require '[malli.instrument :as mi]) (mi/instrument!) (mi/unstrument!)

Job payload validation interface supporting malli schemas, clojure.spec specs,
and composite chains of validators.

Typical usage:

  ;; From config (malli schemas or clojure.spec keywords in [:schema :job-schemas])
  (def v (create-validator config))

  ;; Directly
  (def v (malli-validator {:send-email [:map [:to :string] [:subject :string]]}))

  ;; Validate
  (validate-payload v :send-email {:to "x@y.com" :subject "Hi"})

To enable malli instrumentation of this namespace:

  (require '[malli.instrument :as mi])
  (mi/instrument!)
  (mi/unstrument!)
raw docstring

composite-validatorclj

(composite-validator validators)

Creates a validator that applies validators in order, threading payload through each. Fails on the first validator that rejects the payload.

Creates a validator that applies validators in order, threading payload through
each. Fails on the first validator that rejects the payload.
sourceraw docstring

create-validatorclj

(create-validator config)

Creates a validator from config. Reads [:schema :job-schemas], treating keyword values as clojure.spec spec names and all other values as malli schemas. Returns a no-op validator when :validate-payloads is false or no schemas are defined.

Creates a validator from config. Reads [:schema :job-schemas], treating keyword
values as clojure.spec spec names and all other values as malli schemas.
Returns a no-op validator when :validate-payloads is false or no schemas are defined.
sourceraw docstring

explain-payloadclj

(explain-payload validator task-identifier payload)

Returns nil if payload is valid, or a humanised error map otherwise. Returns nil when no schema is registered for the task.

Returns nil if payload is valid, or a humanised error map otherwise.
Returns nil when no schema is registered for the task.
sourceraw docstring

malli-validatorclj

(malli-validator schemas)

Creates a validator that uses malli schemas keyed by task-identifier keyword. schemas is a map of keyword to malli schema, e.g. {:my-task [:map [:id :int]]}.

Creates a validator that uses malli schemas keyed by task-identifier keyword.
schemas is a map of keyword to malli schema, e.g. {:my-task [:map [:id :int]]}.
sourceraw docstring

noop-validatorclj

(noop-validator)

Creates a no-op validator that accepts all payloads without validation.

Creates a no-op validator that accepts all payloads without validation.
sourceraw docstring

spec-validatorclj

(spec-validator specs)

Creates a validator that uses clojure.spec specs keyed by task-identifier keyword. specs is a map of keyword to spec, e.g. {:my-task ::my-spec}.

Creates a validator that uses clojure.spec specs keyed by task-identifier keyword.
specs is a map of keyword to spec, e.g. {:my-task ::my-spec}.
sourceraw docstring

valid-payload?clj

(valid-payload? validator task-identifier payload)

Returns true if payload is valid for task-identifier, false otherwise. Returns true when no schema is registered for the task.

Returns true if payload is valid for task-identifier, false otherwise.
Returns true when no schema is registered for the task.
sourceraw docstring

validate-payloadclj

(validate-payload validator task-identifier payload)

Validates payload for task-identifier. Returns payload on success, throws ex-info with :task-identifier, :errors, and :payload keys on failure. Passes payload through unchanged when no schema is registered for the task.

Validates payload for task-identifier. Returns payload on success, throws
ex-info with :task-identifier, :errors, and :payload keys on failure.
Passes payload through unchanged when no schema is registered for the task.
sourceraw 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