Simple validator for french phone numbers

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


Yii 1.1


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');

Leave a comment

Please to leave your comment.

Create extension