NotEmpty.php 684 B

1234567891011121314151617181920212223242526272829303132333435
  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 is_string;
  9. use function trim;
  10. /**
  11. * Validates whether the input is not empty
  12. *
  13. * @author Alexandre Gomes Gaigalas <alganet@gmail.com>
  14. * @author Bram Van der Sype <bram.vandersype@gmail.com>
  15. * @author Henrique Moody <henriquemoody@gmail.com>
  16. */
  17. final class NotEmpty extends AbstractRule
  18. {
  19. /**
  20. * {@inheritDoc}
  21. */
  22. public function validate($input): bool
  23. {
  24. if (is_string($input)) {
  25. $input = trim($input);
  26. }
  27. return !empty($input);
  28. }
  29. }