Skip to content

Model Configuration

validatesNumericalityOf()

validatesNumericalityOf() — returns void

Available in: model Category: Validation Functions

Validates that the value of the specified property is numeric.

NameTypeRequiredDefaultDescription
propertiesstringnoName of property or list of property names to validate against (can also be called with the property argument).
messagestringno[property] is not a numberSupply a custom error message here to override the built-in one.
whenstringnoonSavePass in onCreate or onUpdate to limit when this validation occurs (by default validation will occur on both create and update, i.e. onSave).
allowBlankbooleannofalseIf set to true, validation will be skipped if the property value is an empty string or doesn’t exist at all. This is useful if you only want to run this validation after it passes the validatesPresenceOf test, thus avoiding duplicate error messages if it doesn’t.
onlyIntegerbooleannofalseSpecifies whether the property value must be an integer.
conditionstringnoString expression to be evaluated that decides if validation will be run (if the expression returns true validation will run).
unlessstringnoString expression to be evaluated that decides if validation will be run (if the expression returns false validation will run).
oddbooleanno
evenbooleanno
greaterThannumericnoSpecifies whether or not the value must be greater than the supplied value.
greaterThanOrEqualTonumericnoSpecifies whether or not the value must be greater than or equal the supplied value.
equalTonumericnoSpecifies whether or not the value must be equal to the supplied value.
lessThannumericnoSpecifies whether or not the value must be less than the supplied value.
lessThanOrEqualTonumericnoSpecifies whether or not the value must be less than or equal the supplied value.