protected function Url::getRules in Clientside Validation 3.0.x
Same name and namespace in other branches
- 8.2 src/Plugin/CvValidator/Url.php \Drupal\clientside_validation\Plugin\CvValidator\Url::getRules()
- 8 src/Plugin/CvValidator/Url.php \Drupal\clientside_validation\Plugin\CvValidator\Url::getRules()
- 2.0.x src/Plugin/CvValidator/Url.php \Drupal\clientside_validation\Plugin\CvValidator\Url::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/ Url.php, line 26
Class
- Url
- Provides a 'url' validator.
Namespace
Drupal\clientside_validation\Plugin\CvValidatorCode
protected function getRules($element, FormStateInterface $form_state) {
$message = $element['#url_error'] ?? $this
->t('@title does not contain a valid url.', [
'@title' => $this
->getElementTitle($element),
]);
return [
'messages' => [
'url' => $message,
],
];
}