1 | <?php |
||
20 | class Phone extends Rule |
||
21 | { |
||
22 | /** |
||
23 | * Constants that will be used when an invalid phone number is passed. |
||
24 | */ |
||
25 | const INVALID_VALUE = 'Phone::INVALID_VALUE'; |
||
26 | const INVALID_FORMAT = 'Phone::INVALID_FORMAT'; |
||
27 | |||
28 | /** |
||
29 | * The message templates which can be returned by this validator. |
||
30 | * |
||
31 | * @var array |
||
32 | */ |
||
33 | protected $messageTemplates = [ |
||
34 | self::INVALID_VALUE => '{{ name }} must be a valid phone number', |
||
35 | self::INVALID_FORMAT => '{{ name }} must have a valid phone number format', |
||
36 | ]; |
||
37 | |||
38 | /** |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $countryCode; |
||
42 | |||
43 | /** |
||
44 | * Construct the Phone validator. |
||
45 | * |
||
46 | * @param string $countryCode |
||
47 | */ |
||
48 | 13 | public function __construct($countryCode) |
|
52 | |||
53 | /** |
||
54 | * Validates if $value is a valid phone number. |
||
55 | * |
||
56 | * @param mixed $value |
||
57 | * @return bool |
||
58 | */ |
||
59 | 13 | public function validate($value) |
|
74 | } |
||
75 |