1 | <?php |
||
21 | class PhoneNumberValidator extends Validator |
||
22 | { |
||
23 | /** |
||
24 | * @var string If a phone number does not contain the country prefix (+41 f.e), define a default country format which then defines the |
||
25 | * country prefix. |
||
26 | * |
||
27 | * ```php |
||
28 | * 'country' => 'CH', |
||
29 | * ``` |
||
30 | */ |
||
31 | public $country; |
||
32 | |||
33 | /** |
||
34 | * @var boolean Whether the phone number value should be standardized with formating function and write back to the model. This is usefull |
||
35 | * in order to have all phone numbers save in the correct format in the database. |
||
36 | */ |
||
37 | public $autoFormat = true; |
||
38 | |||
39 | /** |
||
40 | * @var inter The format which should be taken to auto format the phone number value. |
||
41 | */ |
||
42 | public $autoFormatFormat = PhoneNumberFormat::E164; |
||
43 | |||
44 | /** |
||
45 | * @var integer If enabled, the validator will check the type of number. This can be usefull to test for mobile phone numbers. |
||
46 | * |
||
47 | * An example to check for mobile phone numbers: |
||
48 | * |
||
49 | * ```php |
||
50 | * 'type' => \libphonenumber\PhoneNumberType::MOBILE |
||
51 | * ``` |
||
52 | */ |
||
53 | public $type; |
||
54 | |||
55 | /** |
||
56 | * {@inheritDoc} |
||
57 | */ |
||
58 | public function validateAttribute($model, $attribute) |
||
85 | } |