(boolean)
(boolean {:keys [msg] :or {msg "This must be a boolean."}})
Indicates the field must be a boolean.
Indicates the field must be a boolean.
(comp & fns)
Compose multiple validators together.
Compose multiple validators together.
(default d)
Provides a default value to be used when the provided value is nil.
Provides a default value to be used when the provided value is nil.
(double)
(double {:keys [msg] :or {msg "This must be a double."}})
Indicates the field must be a double.
Indicates the field must be a double.
(error v)
Use this function to return an error on validation failure.
Use this function to return an error on validation failure.
(error-value v)
Returns the error value from v
.
Returns the error value from `v`.
(error? v)
Returns true if v
contains an error.
Returns true if `v` contains an error.
(float)
(float {:keys [msg] :or {msg "This must be a float."}})
Indicates the field must be a float.
Indicates the field must be a float.
(greater-or-equal target)
(greater-or-equal target
{:keys [msg]
:or {msg "This value is less than the allowed value."}})
Ensure the value is greater than or equal to the provided value.
Comparisons are made using compare
.
Ensure the value is greater than or equal to the provided value. Comparisons are made using `compare`.
(greater-than target)
(greater-than target
{:keys [msg]
:or {msg "This value is less than the allowed value."}})
Ensure the value is greater than the provided value. Comparisons are made
using compare
.
Ensure the value is greater than the provided value. Comparisons are made using `compare`.
(in coll)
(in coll {:keys [msg] :or {msg "This is not one of the allowed values."}})
Indicates the field must be contained as defined by contains?
in the
collection provided as in
.
Indicates the field must be contained as defined by `contains?` in the collection provided as `in`.
(int)
(int {:keys [msg] :or {msg "This must be a integer."}})
Indicates the field must be a integer.
Indicates the field must be a integer.
(keyword)
(keyword {:keys [msg] :or {msg "This must be a keyword."}})
Indicates the field must be a keyword.
Indicates the field must be a keyword.
(less-or-equal target)
(less-or-equal target
{:keys [msg]
:or {msg "This value is more than the allowed value."}})
Ensure the value is less than or equal to the provided value.
Comparisons are made using compare
.
Ensure the value is less than or equal to the provided value. Comparisons are made using `compare`.
(less-than target)
(less-than target
{:keys [msg] :or {msg "This value is more than the allowed value."}})
Ensure the value is less than the provided value. Comparisons are made
using compare
.
Ensure the value is less than the provided value. Comparisons are made using `compare`.
(long)
(long {:keys [msg] :or {msg "This must be a long."}})
Indicates the field must be a long.
Indicates the field must be a long.
(negative)
(negative {:keys [msg] :or {msg "This value must be negative."}})
Ensure the value is negative checked by neg?
.
Ensure the value is negative checked by `neg?`.
(non-empty)
(non-empty {:keys [msg] :or {msg "This value cannot be empty."}})
Ensures the value is non-empty.
Ensures the value is non-empty.
(number)
(number {:keys [msg] :or {msg "This must be a number."}})
Indicates the field must be a number.
Indicates the field must be a number.
(optional)
Indicates the field is optional.
Indicates the field is optional.
(positive)
(positive {:keys [msg] :or {msg "This value must be positive."}})
Ensure the value is positive checked by pos?
.
Ensure the value is positive checked by `pos?`.
(range start end)
(range start
end
{:keys [msg] :or {msg "This value is outside the allowed range."}})
Ensure the value is the given range, start and end inclusive. Comparisons
are made using compare
.
Ensure the value is the given range, start and end inclusive. Comparisons are made using `compare`.
(re-match re)
(re-match re
{:keys [msg]
:or {msg "This value does not match the expected pattern."}})
Ensure the value matches the provided regular expression. If the value is not a string, it is considered not to match.
Ensure the value matches the provided regular expression. If the value is not a string, it is considered not to match.
(required)
(required {:keys [msg] :or {msg "This must be provided."}})
Indicates the field is required.
Indicates the field is required.
(schema m)
(schema m
{:keys [extra msg]
:or {extra :fail msg "This field was not expected."}})
Schema takes a map of keys to validators. Optionally :extra
can be
configured to one of :fail
(the default), :drop
or :pass
to
indicate the behavior of extra keys.
Schema takes a map of keys to validators. Optionally `:extra` can be configured to one of `:fail` (the default), `:drop` or `:pass` to indicate the behavior of extra keys.
(set)
(set {:keys [msg] :or {msg "This must be a set."}})
Indicates the field must be a set.
Indicates the field must be a set.
(string)
(string {:keys [msg] :or {msg "This must be a string."}})
Indicates the field must be a string.
Indicates the field must be a string.
(to-boolean)
(to-boolean {:keys [msg]
:or {msg "This value could not be converted to a boolean."}})
Parse strings using the following rules:
true | yes | enable | on | 1 => true
false | no | disable | off | 0 => false
Parse numbers using the following rules:
1 => true
0 => false
Other values are unacceptable.
Parse strings using the following rules: `true | yes | enable | on | 1 => true` `false | no | disable | off | 0 => false` Parse numbers using the following rules: `1 => true` `0 => false` Other values are unacceptable.
(to-double)
(to-double {:keys [msg]
:or {msg "This value could not be converted to a double."}})
Parse strings using Double/parseDouble
and cast other values using
double
.
Parse strings using `Double/parseDouble` and cast other values using `double`.
(to-float)
(to-float {:keys [msg]
:or {msg "This value could not be converted to a float."}})
Parse strings using Float/parseInt
and cast other values using float
.
Parse strings using `Float/parseInt` and cast other values using `float`.
(to-int)
(to-int {:keys [msg]
:or {msg "This value could not be converted to an integer."}})
Parse strings using Integer/parseInt
and cast other values using int
.
Parse strings using `Integer/parseInt` and cast other values using `int`.
(to-set)
(to-set sc)
Convert a collection or a single value into a set. Optionally applies the given schema to each value.
Convert a collection or a single value into a set. Optionally applies the given schema to each value.
(to-vector)
(to-vector sc)
Convert a collection or a single value into a vector. Optionally applies the given schema to each value.
Convert a collection or a single value into a vector. Optionally applies the given schema to each value.
(trim)
Trims leading and trailing whitespace.
Trims leading and trailing whitespace.
(vector)
(vector {:keys [msg] :or {msg "This must be a vector."}})
Indicates the field must be a vector.
Indicates the field must be a vector.
(zero-or-positive)
(zero-or-positive {:keys [msg]
:or {msg "This value must be zero or positive."}})
Ensure the value is zero or positive checked by pos?
.
Ensure the value is zero or positive checked by `pos?`.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close