Explorar o código

Update Core\Validator

Change the getData() method to be able to exclude the specified elements.
Visman %!s(int64=4) %!d(string=hai) anos
pai
achega
e0b08758f1
Modificáronse 1 ficheiros con 9 adicións e 3 borrados
  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)) {
         if (empty($this->status)) {
             throw new RuntimeException('Data not found');
             throw new RuntimeException('Data not found');
         }
         }
 
 
+        if (null === $doNotUse) {
+            $result = $this->result;
+        } else {
+            $result = \array_diff_key($this->result, \array_flip($doNotUse));
+        }
+
         if ($all) {
         if ($all) {
-            return $this->result;
+            return $result;
         } else {
         } else {
-            return \array_filter($this->result, function ($value) {
+            return \array_filter($result, function ($value) {
                 return null !== $value;
                 return null !== $value;
             });
             });
         }
         }