2017 © Pedro Peláez
 

validator yii2-phone-validator

Yii2 Phone validator wrapper on top of PhoneNumberUtil library also used by Android devices

image

udokmeci/yii2-phone-validator

Yii2 Phone validator wrapper on top of PhoneNumberUtil library also used by Android devices

  • Friday, September 16, 2016
  • by udokmeci
  • Repository
  • 1 Watchers
  • 25 Stars
  • 35,022 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 11 Forks
  • 3 Open issues
  • 3 Versions
  • 7 % Grown

The README.md

yii2-phone-validator

Yii2 phone validator is a validator uses phone number util to validate and format the phone number attribute of model., (*1)

How to use?

Installation with Composer

Just add the line under require object in your composer.json file. ``` json { "require": { "udokmeci/yii2-phone-validator" : "~1.0.4" } }, (*2)

then run 

``` console
$> composer update

Configuration

Now add following in to your model rules., (*3)

Note: ISO 3166-1 alpha-2 codes are required for country attribute. You can use db-regions for countries list.

``` php /** * @inheritdoc */ public function rules() { return [ [['name', 'country'], 'string', 'max' => 50], // add this line [['phone'], 'udokmeci\yii2PhoneValidator\PhoneValidator'], ]; }, (*4)

##Advanced
The `country` and `country_code` attributes are tried if `country` or `countryAttribute` is not specified.

``` php
  // All phones will be controlled according to Turkey and formatted to TR Phone Number
  [['phone'], 'udokmeci\yii2PhoneValidator\PhoneValidator','country'=>'TR'],// 

  //All phones will be controlled according to value of $model->country_code
  [['phone'], 'udokmeci\yii2PhoneValidator\PhoneValidator','countryAttribute'=>'country_code'],

  //All phones will be controlled according to value of $model->country_code
  //If model has not a country attribute then phone will not be validated
  //If phone is a valid one will be formatted for International Format. default behavior.
  [['phone'], 'udokmeci\yii2PhoneValidator\PhoneValidator','countryAttribute'=>'country_code','strict'=>false,'format'=>true],  

Any forks are welcome., (*5)

The Versions

16/09 2016

dev-master

9999999-dev https://github.com/udokmeci/yii2-beanstalk

Yii2 Phone validator wrapper on top of PhoneNumberUtil library also used by Android devices

  Sources   Download

MIT

The Requires

 

yii2 phone number phone number validator

14/06 2016

1.0.1

1.0.1.0 https://github.com/udokmeci/yii2-beanstalk

Yii2 Phone validator wrapper on top of PhoneNumberUtil library also used by Android devices

  Sources   Download

MIT

The Requires

 

yii2 phone number phone number validator

10/03 2015

1.0.0

1.0.0.0 https://github.com/udokmeci/yii2-beanstalk

Yii2 Phone validator wrapper on top of PhoneNumberUtil library also used by Android devices

  Sources   Download

MIT

The Requires

 

yii2 phone number phone number validator