Skip to content

Commit 77cef20

Browse files
authored
fix: add nouvelle caledonie telephone format (#49)
1 parent 6068e94 commit 77cef20

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/models/contact/contact.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,16 @@ describe('contact model', (): void => {
9090
telephone: '0 809 36 12 12'
9191
});
9292
});
93+
94+
it('should allow nouvelle caledonie telephone format (indicatif + 6 digits)', (): void => {
95+
const contactData: ContactToValidate = {
96+
telephone: '+687241541'
97+
};
98+
99+
const contact: Contact = Contact(contactData);
100+
101+
expect(contact).toStrictEqual({
102+
telephone: '+687241541'
103+
});
104+
});
93105
});

src/models/contact/contact.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const COURRIEL_REG_EXP: RegExp =
1818
/^[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;
1919

2020
const TELEPHONE_REG_EXP: RegExp =
21-
/^(?:(?:\+|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;
21+
/^(?:(?:\+|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;
2222

2323
export const isValidCourriel = (courriel: string): boolean => COURRIEL_REG_EXP.test(courriel);
2424

0 commit comments

Comments
 (0)