respect-validation/library/Rules/Positive.php
Ismael Elias 72933a718f
Apply contribution guidelines to "Positive" rule
Also does not allow validation of non-numeric values.

Co-Authored-By: Henrique Moody <henriquemoody@gmail.com>
2018-06-05 22:26:58 +02:00

38 lines
806 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 function is_numeric;
/**
* Validates whether the input is a positive number.
*
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Henrique Moody <henriquemoody@gmail.com>
* @author Ismael Elias <ismael.esq@hotmail.com>
*/
final class Positive extends AbstractRule
{
/**
* {@inheritdoc}
*/
public function validate($input): bool
{
if (!is_numeric($input)) {
return false;
}
return $input > 0;
}
}