Skip to content

Commit 146129c

Browse files
fix: disallow accented characters for courriels (#45)
1 parent 78ab47c commit 146129c

File tree

2 files changed

+1
-11
lines changed

2 files changed

+1
-11
lines changed

src/models/contact/contact.spec.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,4 @@ describe('contact model', (): void => {
9090
telephone: '0 809 36 12 12'
9191
});
9292
});
93-
94-
it('should allow accentued characters for courriel', (): void => {
95-
const contactData: ContactToValidate = {
96-
courriel: 'contact@cartographienationalé.fr'
97-
};
98-
99-
const contact: Contact = Contact(contactData);
100-
101-
expect(contact).toStrictEqual({ ...contactData } as Contact);
102-
});
10393
});

src/models/contact/contact.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export type ContactToValidate = Omit<Contact, 'isContact'>;
1616

1717
const COURRIEL_REG_EXP: RegExp =
1818
/* eslint-disable-next-line require-unicode-regexp */
19-
/^(?:(?:[^<>()[\]\\.,;:\s@"]+(?:\.[^<>()[\]\\.,;:\s@"]+)*)|(?:".+"))@(?:(?:\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}])|(?:(?:[A-Za-zÀ-ÖØ-öø-ÿ\-\d]+\.)+[a-zA-Z]{2,}))$/;
19+
/^(?:(?:[^<>()[\]\\.,;:\s@"]+(?:\.[^<>()[\]\\.,;:\s@"]+)*)|(?:".+"))@(?:(?:\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}])|(?:(?:[a-zA-Z\-\d]+\.)+[a-zA-Z]{2,}))$/;
2020

2121
const TELEPHONE_REG_EXP: RegExp =
2222
/^(?:(?:\+|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})|\s\d{3}(?:\s\d{2}){3})$/u;

0 commit comments

Comments
 (0)