As per documentation available for Adding custom validation rules - Webform Validation hooks it is given that,

In hook_webform_validation_validators() , custom_error and custom_data are optional parameters

  • custom_error (optional): define whether a user can specify a custom error message upon creating the validation rule.
  • custom_data (optional): define whether custom data can be added to the validation rule

Accordingly,
I have implemented hook_webform_validation_validators() in my custom module under

function hook_webform_validation_validators() {
  return array(
    'is_empty' => array(
      'name' => "Is Empty",	  
        'component_types' => array(
           'number',
           'textfield', 
           'email', 
          ),	  
        'custom_error' => FALSE,	
        'custom_data' => FALSE,			
        'description' => t('Verifies that a specified field is empty. Recommended use case: Used when want to show'),
       ),
    );
}

But, when I try to use validation on validation rule page, the custom error field shows as required field instead of optional.

Ideally, it should be optional.

CommentFileSizeAuthor
WEBFORM_VALIDATION_TEST.png15.44 KBdineshw
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dineshw created an issue. See original summary.

Liam Morland’s picture

Priority: Major » Normal

Thanks for the report. If you leave out those keys instead of setting them to false it will work. A proper fix is coming.

  • Liam Morland committed a2a5bb3 on 7.x-1.x
    Issue #2560407: Use !empty() instead of isset() to test custom_data,...
Liam Morland’s picture

Title: On implemntation of hook_webform_validation_validators() , custom_error is showing as required field, refer screenshot and code snippest » Use !empty() instead of isset() to test custom_data, negatable, and custom_error in webform_validation_manage_rule()
Status: Active » Fixed

Try the development version.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

dineshw’s picture

Issue summary: View changes
dineshw’s picture

Issue summary: View changes