UNPKG

deep-email-validator

Version:

Validates emails based on regex, common typos, disposable email blacklists, DNS records and SMTP server response.

41 lines (36 loc) 1.09 kB
type Options = { sender: string; validateRegex: boolean; validateMx: boolean; validateTypo: boolean; validateDisposable: boolean; validateSMTP: boolean; }; type MailCheckOptions = { additionalTopLevelDomains?: string[]; }; type ValidatorOptions = Partial<Options> & { email: string; } & MailCheckOptions; declare global { interface ObjectConstructor { typedKeys<T>(o: T): Array<keyof T>; } } type ElementType<T extends ReadonlyArray<unknown>> = T extends ReadonlyArray<infer E> ? E : never; declare const OrderedLevels: readonly ["regex", "typo", "disposable", "mx", "smtp"]; type SubOutputFormat = { valid: boolean; reason?: string | undefined; }; type Level = ElementType<typeof OrderedLevels>; interface GeneralOutputFormat extends SubOutputFormat { reason?: Level | undefined; } type OutputFormat = GeneralOutputFormat & { validators: { [K in Level]?: SubOutputFormat; }; }; declare function validate(emailOrOptions: string | ValidatorOptions): Promise<OutputFormat>; export { validate as default, validate };