public function MustBeEmptyFieldValidationRule::validate in Field Validation 8
Overrides FieldValidationRuleBase::validate
File
- src/
Plugin/ FieldValidationRule/ MustBeEmptyFieldValidationRule.php, line 61
Class
- MustBeEmptyFieldValidationRule
- MustBeEmptyFieldValidationRule.
Namespace
Drupal\field_validation\Plugin\FieldValidationRuleCode
public function validate($params) {
$value = isset($params['value']) ? $params['value'] : '';
$rule = isset($params['rule']) ? $params['rule'] : null;
$context = isset($params['context']) ? $params['context'] : null;
$settings = array();
if (!empty($rule) && !empty($rule->configuration)) {
$settings = $rule->configuration;
}
$pattern = isset($settings['setting']) ? $settings['setting'] : '';
//$settings = $this->rule->settings;
if ($value != '') {
$context
->addViolation($rule
->getErrorMessage());
}
}