Alnum.php 717 B

123456789101112131415161718192021222324252627282930313233
  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 ctype_alnum;
  9. /**
  10. * Validates whether the input is alphanumeric or not.
  11. *
  12. * Alphanumeric is a combination of alphabetic (a-z and A-Z) and numeric (0-9)
  13. * characters.
  14. *
  15. * @author Alexandre Gomes Gaigalas <alganet@gmail.com>
  16. * @author Henrique Moody <henriquemoody@gmail.com>
  17. * @author Nick Lombard <github@jigsoft.co.za>
  18. */
  19. final class Alnum extends AbstractFilterRule
  20. {
  21. /**
  22. * {@inheritDoc}
  23. */
  24. protected function validateFilteredInput(string $input): bool
  25. {
  26. return ctype_alnum($input);
  27. }
  28. }