User Guide
Auto-generation of form validation rules

CRUDigniter can "look into" your database SQL dump, understand the column types and automatically figure out form validation rules. If you follow the conventions below while creating your database, then on the "rules & associations page" these form validation rules can be applied to your add() and edit() methods by clicking on "Auto Build Validation Rules" button. (screenshot below)

Shown below (table) are the database rules and their correponding form validation rules that are considered while auto-applying form validations using the method shown in the above image.

Database Rule Codeigniter Validation Rule Notes
NOT NULL required -
VARCHAR(255) max_length[255] -
int or bigint integer -
decimal or float numeric -
column name contains the string "email" valid_email If the DB column name contains "email" anywhere then, the valid_email rule will be applied.
for ex. user_email, email, email_address, client_email_addr will all satisfy this condition.
Manual form validation rules

While CRUDigniter will do a best effort to guess the form, these form controls can be overridden by manually selecting the form control type in the rules dropdown. (screenshot below)

Shown below (table) are the database rules and their correponding form validation rules that are considered while manual form validations using the method shown in the above image.

Database Rule Codeigniter Validation Rule Notes
required Returns FALSE if the form element is empty.
matches[form_item] matches Returns FALSE if the form element does not match the one in the parameter.
is_unique[table.field] is_unique Returns FALSE if the form element is not unique to the table and field name in the parameter.
min_length[6] min_length Returns FALSE if the form element is shorter then the parameter value.
max_length[12] max_length Returns FALSE if the form element is longer then the parameter value.
exact_length[8] exact_length Returns FALSE if the form element is not exactly the parameter value.
greater_than[8] greater_than Returns FALSE if the form element is less than the parameter value or not numeric.
less_than[8] less_than Returns FALSE if the form element is greater than the parameter value or not numeric.
alpha Returns FALSE if the form element contains anything other than alphabetical characters.
alpha_numeric Returns FALSE if the form element contains anything other than alpha-numeric characters.
alpha_dash Returns FALSE if the form element contains anything other than alpha-numeric characters, underscores or dashes.
numeric Returns FALSE if the form element contains anything other than numeric characters.
integer Returns FALSE if the form element contains anything other than an integer.
decimal Returns FALSE if the form element contains anything other than a decimal number.
is_natural Returns FALSE if the form element contains anything other than a natural number: 0, 1, 2, 3, etc.
is_natural_no_zero Returns FALSE if the form element contains anything other than a natural number, but not zero: 1, 2, 3, etc.
valid_email Returns FALSE if the form element does not contain a valid email address.
valid_emails Returns FALSE if any value provided in a comma separated list is not a valid email.
valid_ip Returns FALSE if the supplied IP is not valid. Accepts an optional parameter of "IPv4" or "IPv6" to specify an IP format.
valid_base64 Returns FALSE if the supplied string contains anything other than valid Base64 characters.