So I have the following… I have a form field mobilePhone that I am trying to validate into an e164 compliant phone number. When I add a user or edit an existing user it never runs this code and tries to validate it. What gives? Any thoughts would be awesome! Ive been stumped for hours…
$validator
->add('mobilePhone', 'checkPhone',[
'rule' => 'checkPhone',
'provider' => 'table',
'message' => 'Please enter a valid phone number in this format: +14345551212'
]);
public function checkPhone($value, array $context){
debug($value);
return (\Cake\Validation\Validation::custom($value, '/^\+?[1-9]\d{1,14}$/i'));
}