Form element based validation library for Drupal FAPI.
To implement an existing form helper validation rule add the desired 'form_helper_validation_validate_element_RULE_TYPE' function name to an element's '#element_validate' array.
<?php
// This element's value would now have to be a valid email address.
$form['mail']['#element_value'][] = 'form_helper_validation_validate_element_email';
?>
If the form element's name contains a validation rule delimited by an underscore, one can just call 'form_helper_validation_validate_element_name' which will figure out the correct validation rule.
<?php
// This element uses the 'phone' validation rule because the element's name is home_phone.
// The word 'phone' matches an existing validation rule.
$form['home_phone']['#element_value'][] = 'form_helper_validation_validate_element_name';
?>
Validation rules include:
Note
| Name | Description |
|---|---|
| form_helper_validation_has_rule | Check if validation rule exists |
| form_helper_validation_menu | Implementation of hook_menu(). |
| form_helper_validation_perm | Implementation of hook_perm(). |
| form_helper_validation_validate | Execute validatation for a specified rule type |
| form_helper_validation_validate_element | Execute element validation for any rule including custom rules for other modules. |
| form_helper_validation_validate_element_name | Validate element based on a rule type defined within the element's name. |
| _form_helper_validation_get_rule | Get validation rule |
| _form_helper_validation_get_rules | Get validation rules |
| _form_helper_validation_validate | Validation rule handler for regular expression validation or a custom validation function. |
| _form_helper_validation_validate_date | Validation rule for US date |
| _form_helper_validation_validate_datetime | Validation rule for date and time |
| _form_helper_validation_validate_element | Execute element validatation for a rule type |
| _form_helper_validation_validate_email | Validation rule for e-mail address |
| _form_helper_validation_validate_extensions | Validation rule for file extensions |
| _form_helper_validation_validate_max | Validation rule for maximum number |
| _form_helper_validation_validate_min | Validation rule for minimum number |
| _form_helper_validation_validate_path | Validation rule for path |
| _form_helper_validation_validate_range | Validation rule for number range |
| _form_helper_validation_validate_regex | Validation rule for custom regular expression |
| _form_helper_validation_validate_time | Validation rule for time |
| _form_helper_validation_validate_url | Validation rule for url |
| _form_helper_validation_validate_words | Validation rule for number of words |