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 81f84a8
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", // Original issue example

Check failure on line 149 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 16

Strings must use singlequote

Check failure on line 149 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 10

Strings must use singlequote

Check failure on line 149 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 12

Strings must use singlequote

Check failure on line 149 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 20

Strings must use singlequote

Check failure on line 149 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 14

Strings must use singlequote

Check failure on line 149 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 18

Strings must use singlequote

Check failure on line 149 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 8

Strings must use singlequote
"i18n@exampلe.com", // Arabic

Check failure on line 150 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 16

Strings must use singlequote

Check failure on line 150 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 16

Multiple spaces found before '// Arabic'

Check failure on line 150 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 10

Strings must use singlequote

Check failure on line 150 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 10

Multiple spaces found before '// Arabic'

Check failure on line 150 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 12

Strings must use singlequote

Check failure on line 150 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 12

Multiple spaces found before '// Arabic'

Check failure on line 150 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 20

Strings must use singlequote

Check failure on line 150 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 20

Multiple spaces found before '// Arabic'

Check failure on line 150 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 14

Strings must use singlequote

Check failure on line 150 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 14

Multiple spaces found before '// Arabic'

Check failure on line 150 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 18

Strings must use singlequote

Check failure on line 150 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 18

Multiple spaces found before '// Arabic'

Check failure on line 150 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 8

Strings must use singlequote

Check failure on line 150 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 8

Multiple spaces found before '// Arabic'
"i18n@EXАМПЛЕ.com", // Cyrillic

Check failure on line 151 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 16

Strings must use singlequote

Check failure on line 151 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 16

Multiple spaces found before '// Cyrillic'

Check failure on line 151 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 10

Strings must use singlequote

Check failure on line 151 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 10

Multiple spaces found before '// Cyrillic'

Check failure on line 151 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 12

Strings must use singlequote

Check failure on line 151 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 12

Multiple spaces found before '// Cyrillic'

Check failure on line 151 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 20

Strings must use singlequote

Check failure on line 151 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 20

Multiple spaces found before '// Cyrillic'

Check failure on line 151 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 14

Strings must use singlequote

Check failure on line 151 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 14

Multiple spaces found before '// Cyrillic'

Check failure on line 151 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 18

Strings must use singlequote

Check failure on line 151 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 18

Multiple spaces found before '// Cyrillic'

Check failure on line 151 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 8

Strings must use singlequote

Check failure on line 151 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 8

Multiple spaces found before '// Cyrillic'
"i18n@exамple.com", // Cyrillic

Check failure on line 152 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 16

Strings must use singlequote

Check failure on line 152 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 16

Multiple spaces found before '// Cyrillic'

Check failure on line 152 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 10

Strings must use singlequote

Check failure on line 152 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 10

Multiple spaces found before '// Cyrillic'

Check failure on line 152 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 12

Strings must use singlequote

Check failure on line 152 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 12

Multiple spaces found before '// Cyrillic'

Check failure on line 152 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 20

Strings must use singlequote

Check failure on line 152 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 20

Multiple spaces found before '// Cyrillic'

Check failure on line 152 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 14

Strings must use singlequote

Check failure on line 152 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 14

Multiple spaces found before '// Cyrillic'

Check failure on line 152 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 18

Strings must use singlequote

Check failure on line 152 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 18

Multiple spaces found before '// Cyrillic'

Check failure on line 152 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 8

Strings must use singlequote

Check failure on line 152 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 8

Multiple spaces found before '// Cyrillic'
'i18n@éxample.com', // French

Check failure on line 153 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 16

Multiple spaces found before '// French'

Check failure on line 153 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 10

Multiple spaces found before '// French'

Check failure on line 153 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 12

Multiple spaces found before '// French'

Check failure on line 153 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 20

Multiple spaces found before '// French'

Check failure on line 153 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 14

Multiple spaces found before '// French'

Check failure on line 153 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 18

Multiple spaces found before '// French'

Check failure on line 153 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 8

Multiple spaces found before '// French'
'i18n@eßample.com', // German

Check failure on line 154 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 16

Multiple spaces found before '// German'

Check failure on line 154 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 10

Multiple spaces found before '// German'

Check failure on line 154 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 12

Multiple spaces found before '// German'

Check failure on line 154 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 20

Multiple spaces found before '// German'

Check failure on line 154 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 14

Multiple spaces found before '// German'

Check failure on line 154 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 18

Multiple spaces found before '// German'

Check failure on line 154 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 8

Multiple spaces found before '// German'
"i18n@EXΑΜΠΛΕ.com", // Greek

Check failure on line 155 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 16

Strings must use singlequote

Check failure on line 155 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 10

Strings must use singlequote

Check failure on line 155 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 12

Strings must use singlequote

Check failure on line 155 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 20

Strings must use singlequote

Check failure on line 155 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 14

Strings must use singlequote

Check failure on line 155 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 18

Strings must use singlequote

Check failure on line 155 in test/validators.test.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 8

Strings must use singlequote
"i18n@exαmple.com", // Greek
'i18n@exampłe.com', // Polish
'i18n@eซample.com', // Thai
"i18n@例題.com", // Chinese
"i18n@例え.com", // Japanese
"i18n@사례.com", // Korean
],
});
});

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", // Original issue example
"exampلe.com", // Arabic
"EXАМПЛЕ.com", // Cyrillic
"exамple.com", // Cyrillic
'éxample.com', // French
'eßample.com', // German
"EXΑΜΠΛΕ.com", // Greek
"exαmple.com", // Greek
'exampłe.com', // Polish
'eซample.com', // Thai
"例題.com", // Chinese
"例え.com", // Japanese
"사례.com", // Korean
],
});
});

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

0 comments on commit 81f84a8

Please sign in to comment.