Cake 3.3.7
I am trying too have at least one phone number but I cannot make a validation rule.
What’s wrong with this code :
$validator
->add(‘mobile_phone_number’, ‘length’, [
‘rule’ => [‘minLength’, 10],
‘message’ => ‘Please …’
])
->requirePresence(‘mobile_phone_number’, [
‘on’ => function ($context) {
return empty($context[‘data’][‘landline_phone_number’]
);
}])
;
$validator
->add(‘landline_phone_number’, ‘length’, [
‘rule’ => [‘minLength’, 10],
‘message’ => ‘please …’
])
->requirePresence(‘landline_phone_number’, [
‘on’ => function ($context) {
return empty($context[‘data’][‘mobile_phone_number’]
);
}])
;