mirror of
https://github.com/Respect/Validation.git
synced 2026-03-17 15:50:03 +01:00
54 lines
1.2 KiB
PHP
54 lines
1.2 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of Respect/Validation.
|
|
*
|
|
* (c) Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
|
|
*
|
|
* For the full copyright and license information, please view the "LICENSE.md"
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Respect\Validation\Rules;
|
|
|
|
class AllOf extends AbstractComposite
|
|
{
|
|
public function assert($input)
|
|
{
|
|
$exceptions = $this->validateRules($input);
|
|
$numRules = count($this->rules);
|
|
$numExceptions = count($exceptions);
|
|
$summary = array(
|
|
'total' => $numRules,
|
|
'failed' => $numExceptions,
|
|
'passed' => $numRules - $numExceptions,
|
|
);
|
|
if (!empty($exceptions)) {
|
|
throw $this->reportError($input, $summary)->setRelated($exceptions);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public function check($input)
|
|
{
|
|
foreach ($this->getRules() as $v) {
|
|
if (!$v->check($input)) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public function validate($input)
|
|
{
|
|
foreach ($this->getRules() as $v) {
|
|
if (!$v->validate($input)) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|