RegExValidationConstraint.php in RegEx Field Validation 1.0.x
File
src/Plugin/Validation/Constraint/RegExValidationConstraint.php
View source
<?php
namespace Drupal\regex_field_validation\Plugin\Validation\Constraint;
use Symfony\Component\Validator\Constraint;
class RegExValidationConstraint extends Constraint {
public $regex;
public $errorMessage;
public function __construct($options = NULL) {
if (!empty($options) && is_array($options)) {
$options = [
'regex' => $options['regex'],
'errorMessage' => $options['errorMessage'],
];
parent::__construct($options);
}
else {
drupal_set_message('There was an issue with the RegExValidation module initialisation', 'error');
}
}
}