-
Notifications
You must be signed in to change notification settings - Fork 7
numericality
Myles Megyesi edited this page Oct 6, 2012
·
7 revisions
Validates that the given input represents a number. Accepts strings, integers and floats.
(defvalidator user-validator
[:age :numericality])
(user-validator {:age 10})
; {}
(user-validator {:age "asf"})
; {:age ["is not a number"]}
(defvalidator user-validator
[:age :numericality {:only-integer true}])
(user-validator {:age 10})
; {}
(user-validator {:age 10.0})
; {:age ["is not an integer"]}
(defvalidator user-validator
[:age :numericality {:greater-than 18}])
(user-validator {:age 10})
; {:age ["is not greater than 18"]}
(user-validator {:age 19})
; {}
-
is-not-a-number
The error message to supply if the value is not a number. Default"must be a number"
. -
:only-integer
Accept only Integers. Default(attr)-conifrmation
. -
is-not-an-int
The error message to supply if the:only-integer
validation fails. Default"must be an integer"
. -
:greater-than
Value must be greater than this value. Defaultnil
. -
:is-not-greater-than
The error message to supply if the:greater-than
validation fails. Default"must be greater than %s"
. -
:greater-than-or-equal-to
Value must be greater than or equal to this value. Defaultnil
. -
:is-not-greater-than-or-equal-to
The error message to supply if the:greater-than-or-equal-to
validation fails. Default"must be greater than or equal to %s"
. -
:equal-to
Value must be equal to this value. Defaultnil
. -
:is-not-equal-to
The error message to supply if the:equal-to
validation fails. Default"must be eqaul to %s"
. -
:not-equal-to
Value must not be equal to this value. Defaultnil
. -
:is-equal-to
The error message to supply if the:not-equal-to
validation fails. Default"must not be eqaul to %s"
. -
:less-than
Value must be less than this value. Defaultnil
. -
:is-not-less-than
The error message to supply if the:less-than
validation fails. Default"must be less than %s"
. -
:less-than-or-equal-to
Value must be less than or equal to this value. Defaultnil
. -
:is-not-less-than-or-equal-to
The error message to supply if the:less-than-or-equal-to
validation fails. Default"must be less than or equal to %s"
. -
:odd
Value must be odd. Defaultfalse
. -
:is-not-odd
The error message to supply if the:odd
validation fails. Default"must be odd"
. -
:even
Value must be even. Defaultfalse
. -
:is-not-even
The error message to supply if the:even
validation fails. Default"must be even"
. -
:in
Value must be in the given collection. Defaultnil
. -
:is-not-in
The error message to supply if the:in
validation fails. Default"must be included in the list"
. -
:not-in
Value must not be in the given collection. Defaultnil
. -
:is-in
The error message to supply if the:not-in
validation fails. Default"must be not included in the list"
.