Tweak validation for mobile phone number. #339

This commit is contained in:
Korina Cordero 2020-02-13 04:04:28 +00:00
parent 51e333de8b
commit 62edf0f12c

View file

@ -321,9 +321,7 @@ class CMBCustomerHandler implements CustomerHandlerInterface
$verror_array = [];
if (!($this->validateMobileNumber($req->request->get('phone_mobile'))))
{
$error_array['phone_mobile'] = 'Invalid mobile phone number.'
}
$error_array['phone_mobile'] = 'Invalid mobile phone number.';
// TODO: validate vehicles
@ -693,12 +691,12 @@ class CMBCustomerHandler implements CustomerHandlerInterface
{
if (empty($mobile_number))
return true;
if (strlen($mobile_number) != 9)
return false;
if(preg_match('/^\d+$/',$mobile_number))
return true;
// parse string in case multiple numbers are entered separated by
// either a space, a slash, a backslash, a pipe or a comma
$delimiters = [',', ' ', '\\', '/', '|'];
$clean_mobile = str_replace($delimiters, $delimiters[0], $mobile_number);
$mnumber_array = explode($delimiters[0], $clean_mobile);
return false;
}
// check if datatable filter is present and append to query