mirror of
https://github.com/Respect/Validation.git
synced 2024-06-01 13:22:24 +02:00
788939e359
In version 2.3, the Phone rule started to require "giggly/libphonenumber-for-php" as a dependency. That was a backward compatibility break, but the validation also became stricter, and phone numbers without country codes would not be considered valid. This commit will revert the backward compatibility break. That way, when validating a phone number without a country code (the behaviour from version 2.2), the Phone will not use an external library. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
36 lines
736 B
Markdown
36 lines
736 B
Markdown
# Phone
|
|
|
|
- `Phone()`
|
|
- `Phone(string $countyCode)`
|
|
|
|
Validates whether the input is a valid phone number.
|
|
|
|
```php
|
|
v::phone()->validate('+1 650 253 00 00'); // true
|
|
v::phone('BR')->validate('+55 11 91111 1111'); // true
|
|
v::phone('BR')->validate('11 91111 1111'); // false
|
|
```
|
|
|
|
## Note
|
|
|
|
When validating with `$countryCode`, this rule will require the `giggsey/libphonenumber-for-php-lite` package.
|
|
|
|
## Categorization
|
|
|
|
- Strings
|
|
|
|
## Changelog
|
|
|
|
| Version | Description |
|
|
|--------:|-------------------------------------|
|
|
| 2.3.0 | Introduced a validation per country |
|
|
| 0.5.0 | Created |
|
|
|
|
***
|
|
See also:
|
|
|
|
- [Email](Email.md)
|
|
- [Json](Json.md)
|
|
- [Url](Url.md)
|
|
- [VideoUrl](VideoUrl.md)
|