Skip to content

Miscellaneous

validatesInclusionOf()

validatesInclusionOf() — returns any

Validates that the value of the specified property exists in the supplied list.

NameTypeRequiredDefaultDescription
propertiesstringyesName of property or list of property names to validate against (can also be called with the property argument).
liststringyesList of allowed values.
messagestringyes[property] is not included in the listSupply a custom error message here to override the built-in one.
whenstringyesonSavePass in onCreate or onUpdate to limit when this validation occurs (by default validation will occur on both create and update, i.e. onSave).
allowBlankbooleanyesfalseIf 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.
conditionstringyesString expression to be evaluated that decides if validation will be run (if the expression returns true validation will run).
unlessstringyesString expression to be evaluated that decides if validation will be run (if the expression returns false validation will run).
// Make sure that the user selects either "CFWheels" or "Rails" as their framework validatesInclusionOf( property="frameworkOfChoice", list="cfwheels,rails", message="Please try again, and this time, select a decent framework!" );