Return to v2.5.0 docs

validatesExclusionOf()


Model Configuration Validation Functions void model


Validates that the value of the specified property does not exist in the supplied list.

Name Type Required Default Description
properties string No Name of property or list of property names to validate against (can also be called with the property argument).
list string Yes Single value or list of values that should not be allowed.
message string No [property] is reserved Supply a custom error message here to override the built-in one.
when string No onSave Pass in onCreate or onUpdate to limit when this validation occurs (by default validation will occur on both create and update, i.e. onSave).
allowBlank boolean No false If set to true, validation will be skipped if the property value is an empty string or doesn't exist at all. This is useful if you only want to run this validation after it passes the validatesPresenceOf test, thus avoiding duplicate error messages if it doesn't.
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).
// Do not allow "PHP" or "Fortran" to be saved to the database as a cool language
validatesExclusionOf(property="coolLanguage", list="php,fortran", message="Haha, you can not be serious. Try again, please.");

Related Functions

Validation Functions