From 1914dc759dea32b655d413b0a69149b7581acd79 Mon Sep 17 00:00:00 2001 From: Robert Deniszczyc Date: Thu, 12 Dec 2024 09:39:32 +0000 Subject: [PATCH] Support +447 and 07 for ukmobilephone validator Updates the ukmobilephone validator to support numbers starting with 07 or +447 --- controller/validation/validators.js | 2 +- test/controller/spec/validators.spec.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/controller/validation/validators.js b/controller/validation/validators.js index 94c8a0c1..0d01a43c 100644 --- a/controller/validation/validators.js +++ b/controller/validation/validators.js @@ -109,7 +109,7 @@ module.exports = Validators = { }, ukmobilephone(value) { - return value === '' || Validators.regex(value, /^(07)\d{9}$/); + return value === '' || Validators.regex(value, /^(?:\+447|07)\d{9}$/); }, date(value) { diff --git a/test/controller/spec/validators.spec.js b/test/controller/spec/validators.spec.js index b187b15c..14405ac0 100644 --- a/test/controller/spec/validators.spec.js +++ b/test/controller/spec/validators.spec.js @@ -396,7 +396,6 @@ describe('Validators', () => { describe('ukmobilephone', () => { describe('invalid values', () => { const inputs = [ - '+447812123456', '+4407812123456', '+44(0)7812123456', '447812123456', @@ -420,7 +419,8 @@ describe('Validators', () => { describe('valid values', () => { const inputs = [ '', - '07812123456' + '07812123456', + '+447812123456' ]; inputs.forEach(i => { it(testName(i), () => {