Skip to content

Commit 581e7de

Browse files
committed
feat: added test cases to validate changes
1 parent 73da598 commit 581e7de

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

test/validators.test.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,48 @@ describe('Validators', () => {
377377
});
378378
});
379379

380+
it('should reject email addresses with zero-width characters when allow_zero_width is false', () => {
381+
test({
382+
validator: 'isEmail',
383+
args: [{ allow_zero_width: false }],
384+
valid: [
385+
386+
387+
388+
],
389+
invalid: [
390+
391+
'foo@bar\u200B.com',
392+
393+
'test@exam\u200Cple.com',
394+
395+
'user@dom\u200Dain.com',
396+
397+
'admin@si\uFEFFte.com',
398+
],
399+
});
400+
});
401+
402+
it('should allow email addresses with zero-width characters by default', () => {
403+
test({
404+
validator: 'isEmail',
405+
valid: [
406+
407+
408+
409+
'foo@bar\u200B.com',
410+
411+
412+
413+
],
414+
invalid: [
415+
'invalidemail@',
416+
'invalid.com',
417+
'@invalid.com',
418+
],
419+
});
420+
});
421+
380422
it('should validate URLs', () => {
381423
test({
382424
validator: 'isURL',

0 commit comments

Comments
 (0)