Return to v2.1 docs

validateOnCreate()


Model Configuration Validation Functions void model


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

Name Type Required Default Description
methods string No Method name or list of method names to call. Can also be called with the method argument.
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).
function config(){
// Register the `checkPhoneNumber` method below to be called to validate new objects before they are inserted.
validateOnCreate("checkPhoneNumber");
}
function checkPhoneNumber(){
// Make sure area code is `614`.
return Left(this.phoneNumber, 3) == "614";
}

Related Functions

Validation Functions