FloatVal.php 733 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. /*
  3. * Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
  4. * SPDX-License-Identifier: MIT
  5. */
  6. declare(strict_types=1);
  7. namespace Respect\Validation\Rules;
  8. use function filter_var;
  9. use function is_float;
  10. use const FILTER_VALIDATE_FLOAT;
  11. /**
  12. * Validate whether the input value is float.
  13. *
  14. * @author Alexandre Gomes Gaigalas <alganet@gmail.com>
  15. * @author Danilo Benevides <danilobenevides01@gmail.com>
  16. * @author Henrique Moody <henriquemoody@gmail.com>
  17. * @author Jayson Reis <santosdosreis@gmail.com>
  18. */
  19. final class FloatVal extends AbstractRule
  20. {
  21. /**
  22. * {@inheritDoc}
  23. */
  24. public function validate($input): bool
  25. {
  26. return is_float(filter_var($input, FILTER_VALIDATE_FLOAT));
  27. }
  28. }