EqualTo.php in Clientside Validation 8.2
File
clientside_validation_jquery/src/Plugin/CvValidator/EqualTo.php
View source
<?php
namespace Drupal\clientside_validation_jquery\Plugin\CvValidator;
use Drupal\clientside_validation\CvValidatorBase;
use Drupal\Core\Form\FormStateInterface;
class EqualTo extends CvValidatorBase {
protected function getRules($element, FormStateInterface $form_state) {
$message = $element['#equal_to_error'] ?? $this
->t('Value in @field does not match.', [
'@field' => $this
->getElementTitle($element),
]);
return [
'rules' => [
'equalTo' => '[name="' . $element['#equal_to'] . '"]',
],
'messages' => [
'equalTo' => $message,
],
];
}
}
Classes
Name |
Description |
EqualTo |
Provides a 'equalTo' validator. |