Skip to content

Instantly share code, notes, and snippets.

@grandmanitou
Created February 7, 2014 09:02
Show Gist options
  • Save grandmanitou/8859378 to your computer and use it in GitHub Desktop.
Save grandmanitou/8859378 to your computer and use it in GitHub Desktop.
Cakephp 2.x validation of french phone number
/**
* 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