From 14547eaa3dbbc2dd86a2b3f5ff10ca204ac90b18 Mon Sep 17 00:00:00 2001 From: Arthur Belkhayat Date: Fri, 22 Mar 2024 17:52:39 +0100 Subject: [PATCH] feat: allow multi email in contact field --- src/models/contact/contact.spec.ts | 12 ++++++++++++ src/models/contact/contact.ts | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/models/contact/contact.spec.ts b/src/models/contact/contact.spec.ts index 9232f70..5b9c6f1 100644 --- a/src/models/contact/contact.spec.ts +++ b/src/models/contact/contact.spec.ts @@ -102,4 +102,16 @@ describe('contact model', (): void => { telephone: '+687241541' }); }); + + it('should allow multi email in courriel field separated by ;', (): void => { + const contactData: ContactToValidate = { + courriel: 'test@mairie.fr;test2@mairie.fr' + }; + + const contact: Contact = Contact(contactData); + + expect(contact).toStrictEqual({ + courriel: 'test@mairie.fr;test2@mairie.fr' + }); + }); }); diff --git a/src/models/contact/contact.ts b/src/models/contact/contact.ts index 2080415..12037cd 100644 --- a/src/models/contact/contact.ts +++ b/src/models/contact/contact.ts @@ -15,7 +15,7 @@ export type Contact = Model< export type ContactToValidate = Omit; const COURRIEL_REG_EXP: RegExp = - /^[a-zA-Z0-9_][a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9])+$/u; + /^(?:[a-zA-Z0-9_][a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9])+(?:;|$))+$/u; const TELEPHONE_REG_EXP: RegExp = /^(?:(?:\+|00)(?:33|594|262|596|269|687|689|590|508|681)[\s.-]{0,3}(?:\(0\)[\s.-]{0,3})?|0)(?:(?:[1-9](?:[\s.-]?\d{2}){4}|\d{2}(?:[\s.-]\d{3}){2})|\d{6}|\s\d{3}(?:\s\d{2}){3})$/u;