Miscellaneous
validate()
Signature
Section titled “Signature”validate() — returns any
Description
Section titled “Description”Registers method(s) that should be called to validate objects before they are saved.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
methods | string | yes | — | Method name or list of method names to call. (Can also be called with the method argument.) |
condition | string | yes | — | See documentation for validatesConfirmationOf. |
unless | string | yes | — | See documentation for validatesConfirmationOf. |
when | string | yes | onSave | See documentation for validatesConfirmationOf. |
Examples
Section titled “Examples”<cffunction name="init">
<cfscript>
// Register the `checkPhoneNumber` method below to be called to validate objects before they are saved
validate("checkPhoneNumber");
</cfscript>
</cffunction>
<cffunction name="checkPhoneNumber">
<cfscript>
// Make sure area code is `614`
return Left(this.phoneNumber, 3) == "614";
</cfscript>
</cffunction>