Skip to content

Miscellaneous

validate()

validate() — returns any

Registers method(s) that should be called to validate objects before they are saved.

NameTypeRequiredDefaultDescription
methodsstringyesMethod name or list of method names to call. (Can also be called with the method argument.)
conditionstringyesSee documentation for validatesConfirmationOf.
unlessstringyesSee documentation for validatesConfirmationOf.
whenstringyesonSaveSee documentation for validatesConfirmationOf.
<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>