"Validators" allows you to use the Symfony Validator component inside your Drupal projects. The module allows you to extend your forms with an extra parameter called #validators. This validator is designed to validate forms against constraints (i.e. rules). An overview of these constraints can be found on the official component page.


API Hooks

  1. hook_validator_asserts: Introduce custom validator assertions to the form validator.


In the following example we will validate if the user filled in a valid e-mail address and a valid ISBN number:

function mymodule_personal_details_form($form, &$form_state) {

  $form['email_address'] = array(
    '#type' => 'textfield',
    '#title' => t('E-mail address'),
    '#validators' => array(

  $form['iban'] = array(
    '#type' => 'textfield',
    '#title' => t('Bank account (IBAN format)'),
    '#validators' => array(
      'Iban' => array(
        'message' => t(
          'This value is an invalid bank account number. Please respect the <a href="@url">IBAN format</a>.',
          array('@url' => '')

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),

  return $form;
Supporting organizations: 
sponsored development of this module

Project Information