miserenkov/yii2-phone-validator

Yii2 phone validator

Installs: 7 798

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:yii2-extension

v1.1 2017-03-17 12:15 UTC

This package is auto-updated.

Last update: 2020-02-04 11:35:27 UTC


README

Yii2 validator for phone numbers

License Latest Stable Version Latest Unstable Version Total Downloads Build Status

Support

GitHub issues.

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()],
        // ...
    ];
}