Available Constraints
propertyName = {
// The field under validation must be yes, on, 1, or true. This is useful for validating "Terms of Service" acceptance.
accepted : any value,
// The field must be alphanumeric ONLY
alpha : any value,
// discrete math modifiers
discrete : (gt,gte,lt,lte,eq,neq):value
// value in list
inList : list,
// max value
max : value,
// Validation method to use in the target object must return boolean accept the incoming value and target object
method : methodName,
// min value
min : value,
// range is a range of values the property value should exist in
range : eg: 1..10 or 5..-5,
// regex validation
regex : valid no case regex
// required field or not, includes null values
required : boolean [false],
// The field under validation must be present and not empty if the `anotherfield` field is equal to the passed `value`.
requiredIf : {
anotherfield:value, anotherfield:value
}
// The field under validation must be present and not empty unless the `anotherfield` field is equal to the passed
requiredUnless : {
anotherfield:value, anotherfield:value
}
// same as but with no case
sameAsNoCase : propertyName
// same as another property
sameAs : propertyName
// size or length of the value which can be a (struct,string,array,query)
size : numeric or range, eg: 10 or 6..8
// specific type constraint, one in the list.
type : (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 to use for validation, must return boolean accept the incoming value and target object, validate(value,target):boolean
udf = variables.UDF or this.UDF or a closure.
// Check if a column is unique in the database
unique = {
table : The table name,
column : The column to check, defaults to the property field in check
}
// Custom validator, must implement coldbox.system.validation.validators.IValidator
validator : path or wirebox id, example: 'mypath.MyValidator' or 'id:MyValidator'
}accepted
alpha
discrete
inList
max
method
min
range
regex
required
requiredIf
requiredUnless
sameAsNoCase
sameAs
size
type
udf
unique
validator
Last updated
Was this helpful?