mirror of
https://github.com/Respect/Validation.git
synced 2026-03-17 15:50:03 +01:00
Because traits are behaviors that are added to a class, it makes sense to name them with the behavior that they add the classes that use them. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
37 lines
819 B
PHP
37 lines
819 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.
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Respect\Validation\Rules;
|
|
|
|
use Respect\Validation\Helpers\CanValidateUndefined;
|
|
|
|
/**
|
|
* Validates if the given input is not optional.
|
|
*
|
|
* By optional we consider null or an empty string ('').
|
|
*
|
|
* @author Danilo Correa <danilosilva87@gmail.com>
|
|
* @author Henrique Moody <henriquemoody@gmail.com>
|
|
*/
|
|
final class NotOptional extends AbstractRule
|
|
{
|
|
use CanValidateUndefined;
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function validate($input): bool
|
|
{
|
|
return false === $this->isUndefined($input);
|
|
}
|
|
}
|