RegexConstraint.php

Same filename in other branches
  1. 8.9.x core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/RegexConstraint.php
  2. 10 core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/RegexConstraint.php
  3. 11.x core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/RegexConstraint.php

Namespace

Drupal\Core\Validation\Plugin\Validation\Constraint

File

core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/RegexConstraint.php

View source
<?php

namespace Drupal\Core\Validation\Plugin\Validation\Constraint;

use Symfony\Component\Validator\Constraints\Regex;

/**
 * Regex constraint.
 *
 * Overrides the symfony constraint to use Drupal-style replacement patterns.
 *
 * @Constraint(
 *   id = "Regex",
 *   label = @Translation("Regex", context = "Validation")
 * )
 */
class RegexConstraint extends Regex {
    public $message = 'This value is not valid.';
    
    /**
     * {@inheritdoc}
     */
    public function validatedBy() {
        return '\\Symfony\\Component\\Validator\\Constraints\\RegexValidator';
    }

}

Classes

Title Deprecated Summary
RegexConstraint Regex constraint.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.