protected function Min::getRules in Clientside Validation 8
Same name and namespace in other branches
- 8.2 src/Plugin/CvValidator/Min.php \Drupal\clientside_validation\Plugin\CvValidator\Min::getRules()
- 3.0.x src/Plugin/CvValidator/Min.php \Drupal\clientside_validation\Plugin\CvValidator\Min::getRules()
- 2.0.x src/Plugin/CvValidator/Min.php \Drupal\clientside_validation\Plugin\CvValidator\Min::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
- src/
Plugin/ CvValidator/ Min.php, line 24
Class
- Min
- Provides a 'min' validator.
Namespace
Drupal\clientside_validation\Plugin\CvValidatorCode
protected function getRules($element, FormStateInterface $form_state) {
$message = $element['#min_error'] ?? $this
->t('The value in @title has to be greater than @min.', [
'@title' => $this
->getElementTitle($element),
'@min' => $this
->getAttributeValue($element, 'min'),
]);
// Drupal already adds the min attribute, so we don't need to set the min
// rule.
return [
'messages' => [
'min' => $message,
],
];
}