Skip to content

Commit 0074aa6

Browse files
authored
🤖 Merge PR DefinitelyTyped#73969 [@types/validator] update isEmail host_blacklist and host_whitelist to accept regex by @weikangchia
1 parent 39e836a commit 0074aa6

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

‎types/validator/lib/isEmail.d.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ export interface IsEmailOptions {
5353
* and the part of the email after the @ symbol matches one of the strings defined in it,
5454
* the validation fails.
5555
*/
56-
host_blacklist?: string[] | undefined;
56+
host_blacklist?: Array<string | RegExp> | undefined;
5757
/**
5858
* If host_whitelist is set to an array of strings
5959
* and the part of the email after the @ symbol matches none of the strings defined in it,
6060
* the validation fails.
6161
*/
62-
host_whitelist?: string[] | undefined;
62+
host_whitelist?: Array<string | RegExp> | undefined;
6363
/**
6464
* If blacklisted_chars receives a string, then the validator will reject emails that include
6565
* any of the characters in the string, in the name part.

‎types/validator/validator-tests.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,11 +725,11 @@ const any: any = null;
725725
};
726726

727727
const isEmailOptionsWithBlacklistedHosts: validator.IsEmailOptions = {
728-
host_blacklist: ["domain"],
728+
host_blacklist: ["domain", /^([a-z0-9\-]+[.])*example[.]com$/],
729729
};
730730

731731
const isEmailOptionsWithWhitelistedHosts: validator.IsEmailOptions = {
732-
host_whitelist: ["domain"],
732+
host_whitelist: ["domain", /^([a-z0-9\-]+[.])*example[.]com$/],
733733
};
734734

735735
const isEmailOptionsWithBlacklistedCharacters: validator.IsEmailOptions = {

0 commit comments

Comments
 (0)