Update Core\Validator
Change the getData() method to be able to exclude the specified elements.
This commit is contained in:
parent
21e1e40e0e
commit
e0b08758f1
1 changed files with 10 additions and 4 deletions
|
@ -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 ($all) {
|
||||
return $this->result;
|
||||
if (null === $doNotUse) {
|
||||
$result = $this->result;
|
||||
} else {
|
||||
return \array_filter($this->result, function ($value) {
|
||||
$result = \array_diff_key($this->result, \array_flip($doNotUse));
|
||||
}
|
||||
|
||||
if ($all) {
|
||||
return $result;
|
||||
} else {
|
||||
return \array_filter($result, function ($value) {
|
||||
return null !== $value;
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue