diff vendor/symfony/validator/ConstraintViolationList.php @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents 4c8ae668cc8c
children 129ea1e6d783
line wrap: on
line diff
--- a/vendor/symfony/validator/ConstraintViolationList.php	Mon Apr 23 09:33:26 2018 +0100
+++ b/vendor/symfony/validator/ConstraintViolationList.php	Mon Apr 23 09:46:53 2018 +0100
@@ -158,4 +158,24 @@
     {
         $this->remove($offset);
     }
+
+    /**
+     * Creates iterator for errors with specific codes.
+     *
+     * @param string|string[] $codes The codes to find
+     *
+     * @return static new instance which contains only specific errors
+     */
+    public function findByCodes($codes)
+    {
+        $codes = (array) $codes;
+        $violations = array();
+        foreach ($this as $violation) {
+            if (in_array($violation->getCode(), $codes, true)) {
+                $violations[] = $violation;
+            }
+        }
+
+        return new static($violations);
+    }
 }