You are here

function _webform_validation_test in Webform Validation 7

Helper function to negate validation rules as needed.

Creates the correct error message.

1 call to _webform_validation_test()
webform_validation_webform_validation_validate in ./webform_validation.validators.inc
Implements hook_webform_validation_validate().

File

./webform_validation.validators.inc, line 1009
Provides validation functionality and hooks.

Code

function _webform_validation_test(&$errors, $key, $rule, $test, array $error_strings = NULL, array $error_vars = NULL) {
  $rule['negate'] = !empty($rule['negate']);
  if ($rule['negate']) {
    $test = !$test;
  }
  if ($test) {
    if ($error_strings) {
      $error = t($error_strings[$rule['negate'] ? 'negated' : 'regular'], $error_vars);
    }
    else {
      $error = _webform_validation_i18n_error_message($rule);
    }
    $errors[$key] = $error;
  }
}