Skip to content

Miscellaneous

validate()

validate() — returns any

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

NameTypeRequiredDefaultDescription
methodsstringyes—Method name or list of method names to call. (Can also be called with the method argument.)
conditionstringyes—See documentation for validatesConfirmationOf.
unlessstringyes—See 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>