Skip to content

Miscellaneous

validatesNumericalityOf()

validatesNumericalityOf() — returns any

Validates that the value of the specified property is numeric.

NameTypeRequiredDefaultDescription
propertiesstringyes—See documentation for validatesConfirmationOf.
messagestringyes[property] is not a numberSee documentation for validatesConfirmationOf.
whenstringyesonSaveSee documentation for validatesConfirmationOf.
allowBlankbooleanyesfalseSee documentation for validatesExclusionOf.
onlyIntegerbooleanyesfalseSpecifies whether the property value must be an integer.
conditionstringyes—See documentation for validatesConfirmationOf.
unlessstringyes—See documentation for validatesConfirmationOf.
oddbooleanyes—Specifies whether or not the value must be an odd number.
evenbooleanyes—Specifies whether or not the value must be an even number.
greaterThannumericyes—Specifies whether or not the value must be greater than the supplied value.
greaterThanOrEqualTonumericyes—Specifies whether or not the value must be greater than or equal the supplied value.
equalTonumericyes—Specifies whether or not the value must be equal to the supplied value.
lessThannumericyes—Specifies whether or not the value must be less than the supplied value.
lessThanOrEqualTonumericyes—Specifies whether or not the value must be less than or equal the supplied value.
// Make sure that the score is a number with no decimals but only when a score is supplied. (Tetting `allowBlank` to `true` means that objects are allowed to be saved without scores, typically resulting in `NULL` values being inserted in the database table)
validatesNumericalityOf(property="score", onlyInteger=true, allowBlank=true, message="Please enter a correct score.");