39 lines
887 B
PHP
39 lines
887 B
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 NoneOf extends AbstractComposite
|
|
{
|
|
public function assert($input)
|
|
{
|
|
$exceptions = $this->validateRules($input);
|
|
$numRules = count($this->getRules());
|
|
$numExceptions = count($exceptions);
|
|
if ($numRules !== $numExceptions) {
|
|
throw $this->reportError($input)->setRelated($exceptions);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public function validate($input)
|
|
{
|
|
foreach ($this->getRules() as $rule) {
|
|
if ($rule->validate($input)) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|