validatesInclusionOf()
Description
Validates that the value of the specified property exists in the supplied list.
Function Syntax
validatesInclusionOf([ properties, list, message, when, allowBlank, if, unless ])
Parameters
| Parameter | 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 | |
List of allowed values. |
message |
string |
No | [property] is not included in the list |
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. |
if |
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). |
Examples
<!--- Make sure that the user selects either "Wheels" or "Rails" as their framework --->
<cfset validatesInclusionOf(property="frameworkOfChoice", list="wheels,rails", message="Please try again and this time select a decent framework.")>
