Преглед на файлове

Update Core\Validator

Change the getData() method to be able to exclude the specified elements.
Visman преди 4 години
родител
ревизия
e0b08758f1
променени са 1 файла, в които са добавени 9 реда и са изтрити 3 реда
  1. 9 3
      app/Core/Validator.php

+ 9 - 3
app/Core/Validator.php

@@ -405,16 +405,22 @@ class Validator
      * Возвращает проверенные данные
      * Поля с ошибками содержат значения по умолчанию или значения с ошибками
      */
-    public function getData(bool $all = false): array
+    public function getData(bool $all = false, array $doNotUse = null): array
     {
         if (empty($this->status)) {
             throw new RuntimeException('Data not found');
         }
 
+        if (null === $doNotUse) {
+            $result = $this->result;
+        } else {
+            $result = \array_diff_key($this->result, \array_flip($doNotUse));
+        }
+
         if ($all) {
-            return $this->result;
+            return $result;
         } else {
-            return \array_filter($this->result, function ($value) {
+            return \array_filter($result, function ($value) {
                 return null !== $value;
             });
         }