-
Notifications
You must be signed in to change notification settings - Fork 90
/
options.ts
36 lines (31 loc) · 947 Bytes
/
options.ts
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
const defaultOptions: ValidatorOptionsFinal = {
email: 'name@example.org',
sender: 'name@example.org',
validateRegex: true,
validateMx: true,
validateTypo: true,
validateDisposable: true,
validateSMTP: true,
}
type Options = {
sender: string
validateRegex: boolean
validateMx: boolean
validateTypo: boolean
validateDisposable: boolean
validateSMTP: boolean
}
type MailCheckOptions = {
additionalTopLevelDomains?: string[]
}
export type ValidatorOptions = Partial<Options> & { email: string } & MailCheckOptions
type ValidatorOptionsFinal = Options & { email: string } & MailCheckOptions
export function getOptions(emailOrOptions: string | ValidatorOptions): ValidatorOptionsFinal {
let options: ValidatorOptionsFinal = defaultOptions
if (typeof emailOrOptions === 'string') {
options = { ...options, email: emailOrOptions }
} else {
options = { ...options, ...emailOrOptions }
}
return options
}