(cached-coerce-fn spec opts)
(coerce spec x)
(coerce spec x opts)
Coerce a value x
using spec/coercer spec
. 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 or matching
symbol. Returns original value in case a coercer can't be found.
Coerce a value `x` using spec/coercer `spec`. 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 or matching symbol. 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. Only works with registered specs
Like coerce, but will call s/assert on the result, making it throw an error if value doesn't comply after coercion. Only works with registered specs
(coerce* spec x opts)
Like coerce, but if it can't find a way to coerce the original value
will return :exoscale.coax/invalid
. Mostly useful for
implementation of special forms like s/or.
Like coerce, but if it can't find a way to coerce the original value will return `:exoscale.coax/invalid`. Mostly useful for implementation of special forms like s/or.
(coerce-fn spec opts)
(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. Only works with registered specs
Like coerce, and will call s/conform on the result. Only works with registered specs
(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 {:as opts :exoscale.coax/keys [enums]})
Tries to find coercer by looking into registry. First looking at :exoscale.coax/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 :exoscale.coax/forms, otherwise it returns the identity coercer
Tries to find coercer by looking into registry. First looking at :exoscale.coax/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 :exoscale.coax/forms, otherwise it returns the identity coercer
(gen-coerce-and [_ & [spec]])
(gen-coerce-coll-of [_ spec & {:as _opts :keys [kind]}])
(gen-coerce-keys [_ & {:as _opts :keys [req-un opt-un req opt]}])
(gen-coerce-map-of [_ kspec vspec & _])
(gen-coerce-merge [_ & spec-forms])
(gen-coerce-multi-spec [_ f retag & _ :as spec-expr])
(gen-coerce-nilable [_ spec])
(gen-coerce-or [_ & pairs])
(gen-coerce-tuple [_ & specs])
(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
(update-cache! cache k coercer)
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close