index.d.ts
1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Code shows a string is valid,
// but docs require string array or object.
type TLDList = string | string[] | { [topLevelDomain: string]: any };
type BaseOptions = {
tldWhitelist?: TLDList;
tldBlacklist?: TLDList;
minDomainAtoms?: number;
allowUnicode?: boolean;
};
type OptionsWithBool = BaseOptions & {
errorLevel?: false;
};
type OptionsWithNumThreshold = BaseOptions & {
errorLevel?: true | number;
};
interface Validator {
/**
* Check that an email address conforms to RFCs 5321, 5322, 6530 and others.
*
* The callback function will always be called
* with the result of the operation.
*
* ```
* import * as IsEmail from "isemail";
*
* const log = result => console.log(`Result: ${result}`);
* IsEmail.validate("test@e.com");
* // => true
* ```
*/
validate(email: string): boolean;
/**
* Check that an email address conforms to RFCs 5321, 5322, 6530 and others.
*
* The callback function will always be called
* with the result of the operation.
*
* ```
* import * as IsEmail from "isemail";
*
* IsEmail.validate("test@iana.org", { errorLevel: false });
* // => true
* ```
*/
validate(email: string, options: OptionsWithBool): boolean;
/**
* Check that an email address conforms to RFCs 5321, 5322, 6530 and others.
*
* The callback function will always be called
* with the result of the operation.
*
* ```
* import * as IsEmail from "isemail";
*
* IsEmail.validate("test@iana.org", { errorLevel: true });
* // => 0
* IsEmail.validate("test @e.com", { errorLevel: 50 });
* // => 0
* IsEmail.validate('test @e.com', { errorLevel: true })
* // => 49
* ```
*/
validate(email: string, options: OptionsWithNumThreshold): number;
}
declare const IsEmail: Validator;
export = IsEmail;