Skip to content

Commit

Permalink
Added test cases for allow_idn option
Browse files Browse the repository at this point in the history
  • Loading branch information
aabboudi committed Oct 16, 2024
1 parent eac4608 commit 9dbfb53
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions test/validators.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,29 @@ describe('Validators', () => {
});
});

it('should not validate email addresses with non-ASCII domain names if allow_idn is set to false', () => {
test({
validator: 'isEmail',
args: [{ allow_idn: false }],
valid: [],
invalid: [
'ka25maj@gˇmail.com',
'i18n@exampلe.com',
'i18n@EXАМПЛЕ.com',
'i18n@exамple.com',
'i18n@éxample.com',
'i18n@eßample.com',
'i18n@EXΑΜΠΛΕ.com',
'i18n@exαmple.com',
'i18n@exampłe.com',
'i18n@eซample.com',
'i18n@例題.com',
'i18n@例え.com',
'i18n@사례.com',
],
});
});

it('should validate email addresses with display names', () => {
test({
validator: 'isEmail',
Expand Down Expand Up @@ -828,6 +851,29 @@ describe('Validators', () => {
});
});

it('should not validate URLs with non-ASCII domain names if allow_idn is set to false', () => {
test({
validator: 'isURL',
args: [{ allow_idn: false }],
valid: [],
invalid: [
'gˇmail.com',
'exampلe.com',
'EXАМПЛЕ.com',
'exамple.com',
'éxample.com',
'eßample.com',
'EXΑΜΠΛΕ.com',
'exαmple.com',
'exampłe.com',
'eซample.com',
'例題.com',
'例え.com',
'사례.com',
],
});
});

it('should validate MAC addresses', () => {
test({
validator: 'isMACAddress',
Expand Down

0 comments on commit 9dbfb53

Please sign in to comment.