schema.coerce

Extension of schema for input coercion (coercing an input to match a schema)

coercer

(coercer schema coercion-matcher)
Inputs: [schema coercion-matcher :- CoercionMatcher]

Produce a function that simultaneously coerces and validates a datum.  Returns
 a coerced value, or a schema.utils.ErrorContainer describing the error.

coercer!

(coercer! schema coercion-matcher)
Inputs: [schema coercion-matcher :- CoercionMatcher]

Like `coercer`, but is guaranteed to return a value that satisfies schema (or throw).

CoercionMatcher

A function from schema to coercion function, or nil if no special coercion is needed.
The returned function is applied to the corresponding data before validation (or walking/
coercion of its sub-schemas, if applicable)

edn-read-string

Reads one object from a string. Returns nil when string is nil or empty

first-matcher

(first-matcher matchers)
Inputs: [matchers :- [CoercionMatcher]]
Returns: CoercionMatcher

A matcher that takes the first match from matchers.

json-coercion-matcher

(json-coercion-matcher schema)
A matcher that coerces keywords and keyword eq/enums from strings, and longs and doubles
from numbers on the JVM (without losing precision)

keyword-enum-matcher

(keyword-enum-matcher schema)

safe

(safe f)
Take a single-arg function f, and return a single-arg function that acts as identity
if f throws an exception, and like f otherwise.  Useful because coercers are not explicitly
guarded for exceptions, and failing to coerce will generally produce a more useful error
in this case.

safe-long-cast

Coerce x to a long if this can be done without losing precision, otherwise return x.

Schema

A Schema for Schemas

set-matcher

(set-matcher schema)

string->boolean

(string->boolean s)
returns true for strings that are equal, ignoring case, to the string 'true'
(following java.lang.Boolean/parseBoolean semantics)

string->keyword

(string->keyword s)

string->uuid

Returns instance of UUID if input is a string.
Note: in CLJS, this does not guarantee a specific UUID string representation,
      similar to #uuid reader

string-coercion-matcher

(string-coercion-matcher schema)
A matcher that coerces keywords, keyword eq/enums, s/Num and s/Int,
and long and doubles (JVM only) from strings.