In the fields.ini file you can specify validation rules to be applied to any field by adding the validators:NAME directive in that field's section of the fields.ini file.
Available Validators
Name
Description
Value
Version
required
Field is required
1
All
maxlength
Maximum number of characters allowed.
$length
All
minlength
Minimum number of characters allowed.
$length
All
rangelength
Range (min and max) characters allows
$min,$max
All
email
Input must be syntactically correct email address.
1
All
emailorblank
Accepts an email address or a blank field.
1
All
regex
Input must match the provided regular expression.
A regular expression
All
lettersonly
Input must contain only letters (i.e. [a-zA-Z]
1
All
numeric
The input must contain a valid positive or negative integer or decimal number.
1
All
nopunctuation
The input must not contain any of these characters: ( ) . / * ^ ? # ! @ $ % + = , " ' > < ~ [ ] { }.
1
All
nonzero
The input must not begin with zero.
1
All
uploadedfile
The element must contain a successfully uploaded file.
1
All
maxfilesize
The uploaded file must be no more than $size bytes.
$size
All
filename
The uploaded file must have a filename that matches the regular expression $file_rx.
$file_rx
All
Examples
To make a the first_name field required we add the following to the fields.ini file:
[first_name]
validators:required=1
Note that fields that are declared NOT NULL in the database are required by default.. If you wanted to remove the required validator from a field that is NOT NULL in the database you would add the following to the fields.ini file: