Validations extends Forms API to add validation procedures, which should minimize the use of custom validation functions.

Currently, it has server-side (i.e. PHP) validations, but will be extended to provide client-side (i.e. JavaScript) validations as well.

Checks included:

  • Type: number, integer, float
  • Min and max number values
  • Min and max selected options (checkboxes and select fields)
  • Min and max string length
  • Valid dates
  • E-mail fields
  • URL fields
  • Regular expressions
  • Custom validation callback functions
  • Require a filed if another field is equal to, different to, greater or lower than a certain value

You can also set your custom global error messages for each validation type in the settings page, but can provide a specific message for any field while building the form, overriding the general settings.

As said, this does not include JavaScript validations for now, but will shortly.

An example of usage follows (note the new '#validations' element):

$form['field'] = array(
       '#type' => 'textfield',
       '#title' => t("A test fied"),
       '#validations' = array(
               'type' => float,
               'min' => 0,
               'max' => 32,
               'callback' => 'callback_function', // arity: ($form, $form_state, $field_name)
               'required-if' => 'other_field!=3', // supported =, ==, !=, <, >, <= and >=. Value can be empty.
       ),
);

I hope this is will serve as a kick-off for a stronger proposal for a validations framework which could possibly include CCK validations.

WARNING: this module is not ready for production use. This is here now to receive feedback, but be warned many features might be changed before it reaches version 1.0

Downloads

Other releases

Version Downloads Date Links
6.x-0.1-alpha2 tar.gz (10.47 KB) | zip (11.93 KB) 2009-Mar-09 Notes

Development releases

Version Downloads Date Links
6.x-0.x-dev tar.gz (12.64 KB) | zip (15.66 KB) 2010-Nov-12 Notes

Project Information

  • Module categories: Developer
  • Maintenance status: Unknown
  • Development status: Unknown
  • Reported installs: 12 sites currently report using this module. View usage statistics.
  • Last modified: July 7, 2010

Maintainers for Validations

  • sebagr - 4 commits
    last: 2 years ago, first: 2 years ago

Issues for Validations

To avoid duplicates, please search before submitting a new issue.
All issues
Bug reports
Oldest open issue: 8 Mar 09