Skip to content

Miscellaneous

validatesNumericalityOf()

validatesNumericalityOf() — returns any

Validates that the value of the specified property is numeric.

NameTypeRequiredDefaultDescription
propertiesstringyesSee 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.
conditionstringyesSee documentation for validatesConfirmationOf.
unlessstringyesSee documentation for validatesConfirmationOf.
oddbooleanyesSpecifies whether or not the value must be an odd number.
evenbooleanyesSpecifies whether or not the value must be an even number.
greaterThannumericyesSpecifies whether or not the value must be greater than the supplied value.
greaterThanOrEqualTonumericyesSpecifies whether or not the value must be greater than or equal the supplied value.
equalTonumericyesSpecifies whether or not the value must be equal to the supplied value.
lessThannumericyesSpecifies whether or not the value must be less than the supplied value.
lessThanOrEqualTonumericyesSpecifies 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.");