Skip to content

Model Configuration

validate()

validate() — returns void

Available in: model Category: Validation Functions

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

NameTypeRequiredDefaultDescription
methodsstringnoMethod name or list of method names to call. Can also be called with the method argument.
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).
whenstringnoonSavePass in onCreate or onUpdate to limit when this validation occurs (by default validation will occur on both create and update, i.e. onSave).
function config() {
	// Register the `checkPhoneNumber` method below to be called to validate objects before they are saved.
	validate("checkPhoneNumber");
}

function checkPhoneNumber() {
	// Make sure area code is `614`.
	return Left(this.phoneNumber, 3) == "614";
}