miserenkov / yii2-phone-validator
Yii2 phone validator
Installs: 21 923
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 0
Type:yii2-extension
Requires
- php: >=7.1
- giggsey/libphonenumber-for-php: ^8
- yiisoft/yii2: ~2
Requires (Dev)
- codeception/codeception: ^4.2
- ergebnis/composer-normalize: ^2.28
- friendsofphp/php-cs-fixer: ^3.15
- phpro/grumphp: ^1.13
- phpstan/phpstan: ^1.10
- proget-hq/phpstan-yii2: ^0.8.0
This package is auto-updated.
Last update: 2024-10-30 01:37:12 UTC
README
Yii2 validator for phone numbers
Support
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist miserenkov/yii2-phone-validator "^1.0"
or add
"miserenkov/yii2-phone-validator": "^1.0"
to the require section of your composer.json
file.
Basic usages
With fixed country value
public function rules() { return [ // ... ['phone', \miserenkov\validators\PhoneValidator::className(), 'country' => 'UA'], // ... ]; }
With fixed country attribute
public function rules() { return [ // ... ['country', 'string'], ['phone', \miserenkov\validators\PhoneValidator::className(), 'countryAttribute' => 'country'], // ... ]; }
With fixed countries value
public function rules() { return [ // ... ['phone', \miserenkov\validators\PhoneValidator::className(), 'countries' => ['UA', 'RU', 'US', /*...*/]], // ... ]; }
With all countries
public function rules() { return [ // ... ['phone', \miserenkov\validators\PhoneValidator::className()], // ... ]; }