Call custom validation before drupal default

Public

Run custom validation check before drupal's default validation for a form.

Get raw version
php
  1. /**
  2. * Implements hook_form_alter().
  3. **/
  4. function MYMODULE_form_alter(&$form, $form_state, $form_id) {
  5. if ($form_id == 'xyz') {
  6. array_unshift($form['#validate'], 'my_xyz_validation_handler');
  7. }
  8.  
  9. function my_xyz_validation_handler($form, &$form_state) {
  10. //Validation logic here.
  11. }