frphonevalidator

Simple validator for french phone numbers
2 followers

Seeing ineersa ukphonevalidator, I remember I add a validator for french phone numbers, so I made it working with Yii

Requirements

Yii 1.1

Usage

Extract FRPhoneValidator.php to your extension directory.

You can now use it as validation rule:

public function rules()
{
   return array(
      array('phone', 'application.extensions.FRPhoneValidator')
           );
}

I kept the allowEmpty possibility.

Total 1 comment

#19082 report it
Clem at 2015/03/10 06:49am
Petite erreur

Thanks for this validator, it works after a litle modification line 31 to 36:

if($value===null || $value==='') {
    if($this->allowEmpty) {
        return true;
    } else {
        $message=$this->message!==null?$this->message:Yii::t('yii','{attribute} is empty');
         $this->addError($object,$attribute,$message);
    }
}

Leave a comment

Please to leave your comment.

Create extension