Available Constraints
Below are all the currently supported constraints. If you need more you can create your own Custom validators as well.
accepted
The field must be yes, on, 1, or true. This is useful for validating "Terms of Service" acceptance.
alpha
The field must be alphabetical ONLY
discrete
The field must pass certain discrete math operations using the format: operator:value
gt
- Greater than the valuegte
- Greater than or equal to the valuelt
- Less than the valuelte
- Less than or equal to the valueeq
- Equal to the valueneq
- Not equal to the value
inList
The field must be in the included list
max
The field must be less than or equal to the defined value
method
The methodName
will be called on the target object and it will pass in validationData and targetValue. It must return a boolean response: true = pass, false = fail.
min
The field must be greater than or equal to the defined value
range
The field must be within the range values and the validation data must follow the range pattern: min..max
regex
The field must pass the regular expression match with no case sensitivity
required
The field must have some type of value and not null.
requiredIf
the field under validation must be present and not empty if the anotherfield
field is equal to the passed value
.
requiredUnless
The field under validation must be present and not empty unless the anotherfield
field is equal to the passed
sameAsNoCase
The field must be the same as another field with no case sensitivity
sameAs
The field must be the same as another field with case sensitivity
size
The field value size must be within the range values and the validation data must follow the range pattern: min..max.
Value can be a (struct,string,array,query)
type
One of the most versatile validators. It can test if the value is of the following specific types:
alpha
array
binary
boolean
component
creditcard
date
email
eurodate
float
GUID
integer
ipaddress
json
numeric
query
ssn
string
struct
telephone
url
usdate
UUID
xml
zipcode
udf
The field value will be passed to the declared closure/lambda to use for validation, must return boolean accept the incoming value and target object, validate(value,target):boolean
unique
The field must be a unique value in a specific database table. The validation data is a struct with the following keys:
table
: The name of the table to checkcolumn
: The column to check, defaults to the property field in check
validator
The field value will be passed to the validator CFC to be used for validation. Please see Custom Validators
Last updated