protected function Pattern::getRules in Clientside Validation 8
Same name and namespace in other branches
- 8.2 clientside_validation_jquery/src/Plugin/CvValidator/Pattern.php \Drupal\clientside_validation_jquery\Plugin\CvValidator\Pattern::getRules()
- 3.0.x clientside_validation_jquery/src/Plugin/CvValidator/Pattern.php \Drupal\clientside_validation_jquery\Plugin\CvValidator\Pattern::getRules()
- 2.0.x clientside_validation_jquery/src/Plugin/CvValidator/Pattern.php \Drupal\clientside_validation_jquery\Plugin\CvValidator\Pattern::getRules()
Get the validation rules for this form element.
Return value
array An array with following keys:
- rules: An array with the rulename as key and the rule arguments as value.
- messages: An array with the rulename as key and the message for this rule as argument.
Overrides CvValidatorBase::getRules
File
- clientside_validation_jquery/
src/ Plugin/ CvValidator/ Pattern.php, line 27
Class
- Pattern
- Provides a 'pattern' validator.
Namespace
Drupal\clientside_validation_jquery\Plugin\CvValidatorCode
protected function getRules($element, FormStateInterface $form_state) {
$message = $element['#pattern_error'] ?? $this
->t('@title does not meet the requirements.', [
'@title' => $this
->getElementTitle($element),
]);
return [
'messages' => [
'pattern' => $message,
],
];
}