| @@ 596-609 (lines=14) @@ | ||
| 593 | } |
|
| 594 | } |
|
| 595 | ||
| 596 | public static function alpha($value, $message = '') |
|
| 597 | { |
|
| 598 | $locale = setlocale(LC_CTYPE, 0); |
|
| 599 | setlocale(LC_CTYPE, 'C'); |
|
| 600 | $valid = !ctype_alpha($value); |
|
| 601 | setlocale(LC_CTYPE, $locale); |
|
| 602 | ||
| 603 | if ($valid) { |
|
| 604 | static::reportInvalidArgument(sprintf( |
|
| 605 | $message ?: 'Expected a value to contain only letters. Got: %s', |
|
| 606 | static::valueToString($value) |
|
| 607 | )); |
|
| 608 | } |
|
| 609 | } |
|
| 610 | ||
| 611 | public static function digits($value, $message = '') |
|
| 612 | { |
|
| @@ 611-624 (lines=14) @@ | ||
| 608 | } |
|
| 609 | } |
|
| 610 | ||
| 611 | public static function digits($value, $message = '') |
|
| 612 | { |
|
| 613 | $locale = setlocale(LC_CTYPE, 0); |
|
| 614 | setlocale(LC_CTYPE, 'C'); |
|
| 615 | $valid = !ctype_digit($value); |
|
| 616 | setlocale(LC_CTYPE, $locale); |
|
| 617 | ||
| 618 | if ($valid) { |
|
| 619 | static::reportInvalidArgument(sprintf( |
|
| 620 | $message ?: 'Expected a value to contain digits only. Got: %s', |
|
| 621 | static::valueToString($value) |
|
| 622 | )); |
|
| 623 | } |
|
| 624 | } |
|
| 625 | ||
| 626 | public static function alnum($value, $message = '') |
|
| 627 | { |
|
| @@ 626-639 (lines=14) @@ | ||
| 623 | } |
|
| 624 | } |
|
| 625 | ||
| 626 | public static function alnum($value, $message = '') |
|
| 627 | { |
|
| 628 | $locale = setlocale(LC_CTYPE, 0); |
|
| 629 | setlocale(LC_CTYPE, 'C'); |
|
| 630 | $valid = !ctype_alnum($value); |
|
| 631 | setlocale(LC_CTYPE, $locale); |
|
| 632 | ||
| 633 | if ($valid) { |
|
| 634 | static::reportInvalidArgument(sprintf( |
|
| 635 | $message ?: 'Expected a value to contain letters and digits only. Got: %s', |
|
| 636 | static::valueToString($value) |
|
| 637 | )); |
|
| 638 | } |
|
| 639 | } |
|
| 640 | ||
| 641 | public static function lower($value, $message = '') |
|
| 642 | { |
|
| @@ 641-654 (lines=14) @@ | ||
| 638 | } |
|
| 639 | } |
|
| 640 | ||
| 641 | public static function lower($value, $message = '') |
|
| 642 | { |
|
| 643 | $locale = setlocale(LC_CTYPE, 0); |
|
| 644 | setlocale(LC_CTYPE, 'C'); |
|
| 645 | $valid = !ctype_lower($value); |
|
| 646 | setlocale(LC_CTYPE, $locale); |
|
| 647 | ||
| 648 | if ($valid) { |
|
| 649 | static::reportInvalidArgument(sprintf( |
|
| 650 | $message ?: 'Expected a value to contain lowercase characters only. Got: %s', |
|
| 651 | static::valueToString($value) |
|
| 652 | )); |
|
| 653 | } |
|
| 654 | } |
|
| 655 | ||
| 656 | public static function upper($value, $message = '') |
|
| 657 | { |
|
| @@ 656-669 (lines=14) @@ | ||
| 653 | } |
|
| 654 | } |
|
| 655 | ||
| 656 | public static function upper($value, $message = '') |
|
| 657 | { |
|
| 658 | $locale = setlocale(LC_CTYPE, 0); |
|
| 659 | setlocale(LC_CTYPE, 'C'); |
|
| 660 | $valid = !ctype_upper($value); |
|
| 661 | setlocale(LC_CTYPE, $locale); |
|
| 662 | ||
| 663 | if ($valid) { |
|
| 664 | static::reportInvalidArgument(sprintf( |
|
| 665 | $message ?: 'Expected a value to contain uppercase characters only. Got: %s', |
|
| 666 | static::valueToString($value) |
|
| 667 | )); |
|
| 668 | } |
|
| 669 | } |
|
| 670 | ||
| 671 | public static function length($value, $length, $message = '') |
|
| 672 | { |
|