Max.php in Clientside Validation 8.2
File
src/Plugin/CvValidator/Max.php
View source
<?php
namespace Drupal\clientside_validation\Plugin\CvValidator;
use Drupal\clientside_validation\CvValidatorBase;
use Drupal\Core\Form\FormStateInterface;
class Max extends CvValidatorBase {
protected function getRules($element, FormStateInterface $form_state) {
$message = $element['#max_error'] ?? $this
->t('The value in @title has to be less than @max.', [
'@title' => $this
->getElementTitle($element),
'@max' => $this
->getAttributeValue($element, 'max'),
]);
return [
'messages' => [
'max' => $message,
],
];
}
}
Classes
Name |
Description |
Max |
Provides a 'max' validator. |