fix phone validation

This commit is contained in:
Dobromir Popov
2024-02-29 00:31:18 +02:00
parent 978ea7e231
commit 8101fbaccd

View File

@ -50,12 +50,12 @@ exports.isValidPhoneNumber = function (phone) {
const cleanedPhone = phone.replace(/\s|-/g, ''); const cleanedPhone = phone.replace(/\s|-/g, '');
// Check if the phone starts with '08' and has 10 digits // Check if the phone starts with '08' and has 10 digits
if (cleanedPhone.startsWith('08') && cleanedPhone.length === 10) { if ((cleanedPhone.startsWith('08') || cleanedPhone.startsWith('07')) && cleanedPhone.length === 10) {
return true; return true;
} }
// Check if the phone starts with '+359' and has the correct length // Check if the phone starts with '+359' and has the correct length
if (cleanedPhone.startsWith('+359') && cleanedPhone.length === 12) { if (cleanedPhone.startsWith('+359') && cleanedPhone.length === 13) {
return true; return true;
} }