(coerce spec x)
(coerce spec x opts)
Coerce a value x
using coercer k
. This function will first try to
use a coercer from the registry, otherwise it will try to infer a
coercer from the spec with the same name. Returns original value in
case a coercer can't be found.
Coerce a value `x` using coercer `k`. This function will first try to use a coercer from the registry, otherwise it will try to infer a coercer from the spec with the same name. Returns original value in case a coercer can't be found.
(coerce! spec x)
(coerce! spec x opts)
Like coerce, but will call s/assert on the result, making it throw an error if value doesn't comply after coercion.
Like coerce, but will call s/assert on the result, making it throw an error if value doesn't comply after coercion.
(coerce-fn spec)
(coerce-fn spec {:exoscale.coax/keys [idents] :as opts})
Get the coercing function from a given key. First it tries to lookup the coercion on the registry, otherwise try to infer from the specs. In case nothing is found, identity function is returned.
Get the coercing function from a given key. First it tries to lookup the coercion on the registry, otherwise try to infer from the specs. In case nothing is found, identity function is returned.
(coerce-structure x)
(coerce-structure x {:exoscale.coax/keys [idents op] :or {op coerce} :as opts})
Recursively coerce map values on a structure.
Recursively coerce map values on a structure.
(conform spec x)
(conform spec x opts)
Like coerce, and will call s/conform on the result.
Like coerce, and will call s/conform on the result.
(def k coercion)
Given a namespace-qualified keyword, and a coerce function, makes an entry in the registry mapping k to the coerce function.
Given a namespace-qualified keyword, and a coerce function, makes an entry in the registry mapping k to the coerce function.
(enum? x)
If the spec is given as a set, and every member of the set is the same type, then we can infer a coercion from that shared type.
If the spec is given as a set, and every member of the set is the same type, then we can infer a coercion from that shared type.
(enum-key x)
takes enum value x
and returns matching predicate to resolve
coercer from registry
takes enum value `x` and returns matching predicate to resolve coercer from registry
(find-coercer spec-exp {:as opts :exoscale.coax/keys [enums]})
Tries to find coercer by looking into registry. First looking at ::idents if value is a qualified-keyword or qualified symbol, or checking if the value is an enum value (homogeneous set) and lastly if it's a s-exp form that indicates a spec form likely it will return it's generated coercer from registry ::form , otherwise the it returns the identity coercer
Tries to find coercer by looking into registry. First looking at ::idents if value is a qualified-keyword or qualified symbol, or checking if the value is an enum value (homogeneous set) and lastly if it's a s-exp form that indicates a spec form likely it will return it's generated coercer from registry ::form , otherwise the it returns the identity coercer
(registry)
returns the registry map, prefer 'get-spec' to lookup a spec by name
returns the registry map, prefer 'get-spec' to lookup a spec by name
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close