Skip to content

Commit 9dbfb53

Browse files
committed
Added test cases for allow_idn option
1 parent eac4608 commit 9dbfb53

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

test/validators.test.js

+46
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,29 @@ describe('Validators', () => {
140140
});
141141
});
142142

143+
it('should not validate email addresses with non-ASCII domain names if allow_idn is set to false', () => {
144+
test({
145+
validator: 'isEmail',
146+
args: [{ allow_idn: false }],
147+
valid: [],
148+
invalid: [
149+
'ka25maj@gˇmail.com',
150+
'i18n@exampلe.com',
151+
'i18n@EXАМПЛЕ.com',
152+
'i18n@exамple.com',
153+
'i18n@éxample.com',
154+
'i18n@eßample.com',
155+
'i18n@EXΑΜΠΛΕ.com',
156+
'i18n@exαmple.com',
157+
'i18n@exampłe.com',
158+
'i18n@eซample.com',
159+
'i18n@例題.com',
160+
'i18n@例え.com',
161+
'i18n@사례.com',
162+
],
163+
});
164+
});
165+
143166
it('should validate email addresses with display names', () => {
144167
test({
145168
validator: 'isEmail',
@@ -828,6 +851,29 @@ describe('Validators', () => {
828851
});
829852
});
830853

854+
it('should not validate URLs with non-ASCII domain names if allow_idn is set to false', () => {
855+
test({
856+
validator: 'isURL',
857+
args: [{ allow_idn: false }],
858+
valid: [],
859+
invalid: [
860+
'gˇmail.com',
861+
'exampلe.com',
862+
'EXАМПЛЕ.com',
863+
'exамple.com',
864+
'éxample.com',
865+
'eßample.com',
866+
'EXΑΜΠΛΕ.com',
867+
'exαmple.com',
868+
'exampłe.com',
869+
'eซample.com',
870+
'例題.com',
871+
'例え.com',
872+
'사례.com',
873+
],
874+
});
875+
});
876+
831877
it('should validate MAC addresses', () => {
832878
test({
833879
validator: 'isMACAddress',

0 commit comments

Comments
 (0)