Created
February 7, 2014 09:02
-
-
Save grandmanitou/8859378 to your computer and use it in GitHub Desktop.
Cakephp 2.x validation of french phone number
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Validation rules | |
* | |
* @var array | |
*/ | |
public $validate = array( | |
'phone_number_1' => array( | |
'notEmpty' => array( | |
'rule' => array('notEmpty'), | |
'message' => 'Obligatoire', | |
//'allowEmpty' => false, | |
//'required' => false, | |
//'last' => false, // Stop validation after this rule | |
//'on' => 'create', // Limit validation to 'create' or 'update' operations | |
), | |
'telephone_fr' => array( | |
'rule' => '/^0[1-9][0-9]{8}$/', | |
'message' => 'Numéro de téléphone invalide', | |
//'allowEmpty' => false, | |
//'required' => false, | |
//'last' => false, // Stop validation after this rule | |
//'on' => 'create', // Limit validation to 'create' or 'update' operations | |
), | |
), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment