Version 1
[yaffs-website] / web / core / lib / Drupal / Core / Validation / Plugin / Validation / Constraint / RegexConstraint.php
diff --git a/web/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/RegexConstraint.php b/web/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/RegexConstraint.php
new file mode 100644 (file)
index 0000000..63c6682
--- /dev/null
@@ -0,0 +1,28 @@
+<?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';
+  }
+
+}