Skip to content

Commit

Permalink
fix: disallow accented characters for courriels
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-gavanier committed Dec 19, 2023
1 parent 78ab47c commit f52c65f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 11 deletions.
10 changes: 0 additions & 10 deletions src/models/contact/contact.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,4 @@ describe('contact model', (): void => {
telephone: '0 809 36 12 12'
});
});

it('should allow accentued characters for courriel', (): void => {
const contactData: ContactToValidate = {
courriel: 'contact@cartographienationalé.fr'
};

const contact: Contact = Contact(contactData);

expect(contact).toStrictEqual({ ...contactData } as Contact);
});
});
2 changes: 1 addition & 1 deletion src/models/contact/contact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type ContactToValidate = Omit<Contact, 'isContact'>;

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

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})|\s\d{3}(?:\s\d{2}){3})$/u;
Expand Down

0 comments on commit f52c65f

Please sign in to comment.