Extension of schema for input coercion (coercing an input to match a schema)
Extension of schema for input coercion (coercing an input to match a schema)
(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.
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! schema coercion-matcher)
Inputs: [schema coercion-matcher :- CoercionMatcher]
Like coercer
, but is guaranteed to return a value that satisfies schema (or throw).
Inputs: [schema coercion-matcher :- CoercionMatcher] Like `coercer`, but is guaranteed to return a value that satisfies schema (or throw).
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)
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)
Reads one object from a string. Returns nil when string is nil or empty
Reads one object from a string. Returns nil when string is nil or empty
(first-matcher matchers)
Inputs: [matchers :- [CoercionMatcher]] Returns: CoercionMatcher
A matcher that takes the first match from matchers.
Inputs: [matchers :- [CoercionMatcher]] Returns: CoercionMatcher A matcher that takes the first match from matchers.
(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)
A matcher that coerces keywords and keyword eq/enums from strings, and longs and doubles from numbers on the JVM (without losing precision)
(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.
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.
Coerce x to a long if this can be done without losing precision, otherwise return x.
Coerce x to a long if this can be done without losing precision, otherwise return x.
(string->boolean s)
returns true for strings that are equal, ignoring case, to the string 'true' (following java.lang.Boolean/parseBoolean semantics)
returns true for strings that are equal, ignoring case, to the string 'true' (following java.lang.Boolean/parseBoolean semantics)
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
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 schema)
A matcher that coerces keywords, keyword eq/enums, s/Num and s/Int, and long and doubles (JVM only) from strings.
A matcher that coerces keywords, keyword eq/enums, s/Num and s/Int, and long and doubles (JVM only) from strings.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close