@@ 622-635 (lines=14) @@ | ||
619 | } |
|
620 | } |
|
621 | ||
622 | public static function alpha($value, $message = '') |
|
623 | { |
|
624 | $locale = setlocale(LC_CTYPE, 0); |
|
625 | setlocale(LC_CTYPE, 'C'); |
|
626 | $valid = !ctype_alpha($value); |
|
627 | setlocale(LC_CTYPE, $locale); |
|
628 | ||
629 | if ($valid) { |
|
630 | static::reportInvalidArgument(sprintf( |
|
631 | $message ?: 'Expected a value to contain only letters. Got: %s', |
|
632 | static::valueToString($value) |
|
633 | )); |
|
634 | } |
|
635 | } |
|
636 | ||
637 | public static function digits($value, $message = '') |
|
638 | { |
|
@@ 637-650 (lines=14) @@ | ||
634 | } |
|
635 | } |
|
636 | ||
637 | public static function digits($value, $message = '') |
|
638 | { |
|
639 | $locale = setlocale(LC_CTYPE, 0); |
|
640 | setlocale(LC_CTYPE, 'C'); |
|
641 | $valid = !ctype_digit($value); |
|
642 | setlocale(LC_CTYPE, $locale); |
|
643 | ||
644 | if ($valid) { |
|
645 | static::reportInvalidArgument(sprintf( |
|
646 | $message ?: 'Expected a value to contain digits only. Got: %s', |
|
647 | static::valueToString($value) |
|
648 | )); |
|
649 | } |
|
650 | } |
|
651 | ||
652 | public static function alnum($value, $message = '') |
|
653 | { |
|
@@ 652-665 (lines=14) @@ | ||
649 | } |
|
650 | } |
|
651 | ||
652 | public static function alnum($value, $message = '') |
|
653 | { |
|
654 | $locale = setlocale(LC_CTYPE, 0); |
|
655 | setlocale(LC_CTYPE, 'C'); |
|
656 | $valid = !ctype_alnum($value); |
|
657 | setlocale(LC_CTYPE, $locale); |
|
658 | ||
659 | if ($valid) { |
|
660 | static::reportInvalidArgument(sprintf( |
|
661 | $message ?: 'Expected a value to contain letters and digits only. Got: %s', |
|
662 | static::valueToString($value) |
|
663 | )); |
|
664 | } |
|
665 | } |
|
666 | ||
667 | public static function lower($value, $message = '') |
|
668 | { |
|
@@ 667-680 (lines=14) @@ | ||
664 | } |
|
665 | } |
|
666 | ||
667 | public static function lower($value, $message = '') |
|
668 | { |
|
669 | $locale = setlocale(LC_CTYPE, 0); |
|
670 | setlocale(LC_CTYPE, 'C'); |
|
671 | $valid = !ctype_lower($value); |
|
672 | setlocale(LC_CTYPE, $locale); |
|
673 | ||
674 | if ($valid) { |
|
675 | static::reportInvalidArgument(sprintf( |
|
676 | $message ?: 'Expected a value to contain lowercase characters only. Got: %s', |
|
677 | static::valueToString($value) |
|
678 | )); |
|
679 | } |
|
680 | } |
|
681 | ||
682 | public static function upper($value, $message = '') |
|
683 | { |
|
@@ 682-695 (lines=14) @@ | ||
679 | } |
|
680 | } |
|
681 | ||
682 | public static function upper($value, $message = '') |
|
683 | { |
|
684 | $locale = setlocale(LC_CTYPE, 0); |
|
685 | setlocale(LC_CTYPE, 'C'); |
|
686 | $valid = !ctype_upper($value); |
|
687 | setlocale(LC_CTYPE, $locale); |
|
688 | ||
689 | if ($valid) { |
|
690 | static::reportInvalidArgument(sprintf( |
|
691 | $message ?: 'Expected a value to contain uppercase characters only. Got: %s', |
|
692 | static::valueToString($value) |
|
693 | )); |
|
694 | } |
|
695 | } |
|
696 | ||
697 | public static function length($value, $length, $message = '') |
|
698 | { |