Model Configuration Validation Functions void model
Validates that the value of the specified property is numeric.
Name | Type | Required | Default | Description |
---|---|---|---|---|
properties | string | No | Name of property or list of property names to validate against (can also be called with the property argument). |
|
message | string | No | [property] is not a number | Supply a custom error message here to override the built-in one. |
when | string | No | onSave | Pass in onCreate or onUpdate to limit when this validation occurs (by default validation will occur on both create and update, i.e. onSave ). |
allowBlank | boolean | No | false | If 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. |
onlyInteger | boolean | No | false | Specifies whether the property value must be an integer. |
condition | string | No | String expression to be evaluated that decides if validation will be run (if the expression returns true validation will run). |
|
unless | string | No | String expression to be evaluated that decides if validation will be run (if the expression returns false validation will run). |
|
odd | boolean | No | ||
even | boolean | No | ||
greaterThan | numeric | No | Specifies whether or not the value must be greater than the supplied value. | |
greaterThanOrEqualTo | numeric | No | Specifies whether or not the value must be greater than or equal the supplied value. | |
equalTo | numeric | No | Specifies whether or not the value must be equal to the supplied value. | |
lessThan | numeric | No | Specifies whether or not the value must be less than the supplied value. | |
lessThanOrEqualTo | numeric | No | 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.");