respect-validation/library/Rules/NotEmpty.php
2018-05-02 16:04:05 +02:00

36 lines
727 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;
/**
* Validates whether the input is not empty
*
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
class NotEmpty extends AbstractRule
{
/**
* {@inheritdoc}
*/
public function validate($input): bool
{
if (is_string($input)) {
$input = trim($input);
}
return !empty($input);
}
}