Paulo, this is what I'm doing with french phone number. I've cut the 
example to the minimum :

file src/Model/Validation/

<?php
namespace App\Model\Validation;


class FrValidationRule
{
    public static function phone($check) {
        $pattern = 
'/^0[1-9]{1}(([0-9]{2}){4})|((\s[0-9]{2}){4})|((-[0-9]{2}){4})|((\.[0-9]{2}){4})$/';
        return (bool)preg_match($pattern, $check);
    }

}



and then in the table :

public function validationDefault(Validator $validator)

{
    $validator->provider('french', 'App\Model\Validation\FrValidationRule');


    $validator
        ->add('phone', 'phone', [
            'rule' => 'phone',
            'provider' => 'french',
            'message' => __('Merci d\'entrer un numéro de téléphone valide.')
        ]);

    return $validator;
}



I hope it will help.

best regards

Le vendredi 12 juin 2015 13:06:04 UTC+2, Paulo Terra a écrit :
>
> Hi, I have been looking for a plugin to validate Person ID, Phone, ZIP 
> Code, etc, but all I can find is for old versions of CakePHP. Does anybody 
> know where I can find a working version for CakePHP 3.0?
>
> Thanks.
>
> Paulo Terra
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Reply via email to