Final Class Yiisoft\Validator\Debug\ValidatorCollector
| Inheritance | Yiisoft\ |
|---|---|
| Implements | Yiisoft\ |
| Uses Traits | Yiisoft\ |
Public Methods
| Method | Description | Defined By |
|---|---|---|
| collect() | Yiisoft\ |
|
| getCollected() | Yiisoft\ |
|
| getSummary() | Yiisoft\ |
Method Details
| public void collect ( mixed $value, Yiisoft\ | ||
| $value | mixed | |
| $result | Yiisoft\ |
|
| $rules | callable|iterable|object|string|null | |
public function collect(mixed $value, Result $result, callable|iterable|object|string|null $rules = null): void
{
if (!$this->isActive()) {
return;
}
if ($rules instanceof Traversable) {
$rules = iterator_to_array($rules);
}
$this->validations[] = [
'value' => $value,
'rules' => $rules,
'result' => $result->isValid(),
'errors' => $result->getErrors(),
];
}
| public array getSummary ( ) |
public function getSummary(): array
{
if (!$this->isActive()) {
return [];
}
$count = count($this->validations);
$countValid = count(array_filter($this->validations, fn(array $data): bool => (bool) $data['result']));
$countInvalid = $count - $countValid;
return [
'total' => $count,
'valid' => $countValid,
'invalid' => $countInvalid,
];
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.