You are here

class RegExValidationConstraint in RegEx Field Validation 1.0.x

Same name and namespace in other branches
  1. 8 src/Plugin/Validation/Constraint/RegExValidationConstraint.php \Drupal\regex_field_validation\Plugin\Validation\Constraint\RegExValidationConstraint
  2. 2.0.x src/Plugin/Validation/Constraint/RegExValidationConstraint.php \Drupal\regex_field_validation\Plugin\Validation\Constraint\RegExValidationConstraint

Checks that the node.

Plugin annotation


@Constraint(
  id = "RegExValidationConstraint",
  label = @Translation("RegEx Validation"),
)

Hierarchy

  • class \Drupal\regex_field_validation\Plugin\Validation\Constraint\RegExValidationConstraint extends \Symfony\Component\Validator\Constraint

Expanded class hierarchy of RegExValidationConstraint

1 string reference to 'RegExValidationConstraint'
regex_field_validation_entity_bundle_field_info_alter in ./regex_field_validation.module
Implements hook_entity_bundle_field_info_alter().

File

src/Plugin/Validation/Constraint/RegExValidationConstraint.php, line 15

Namespace

Drupal\regex_field_validation\Plugin\Validation\Constraint
View source
class RegExValidationConstraint extends Constraint {
  public $regex;
  public $errorMessage;

  /**
   * Class constructor.
   */
  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');
    }
  }

}

Members