/** * Options for configuring email validation constraints. * All lengths are in characters and follow RFC 5321/5322 specifications. */ export interface IsEmailOptions { /** * Maximum total length of the email address (local part + @ + domain). * RFC 5321 recommends a maximum of 320 characters for SMTP. * @default 320 */ maxTotalLength?: number; /** * Maximum length of the local part (before @). * RFC 5321 specifies a maximum of 64 characters for the local part. * @default 64 */ maxLocalPartLength?: number; /** * Maximum length of the domain part (after @). * RFC 1035 specifies a maximum of 255 characters for domain names. * @default 255 */ maxDomainLength?: number; /** * Maximum length of individual domain labels (parts separated by dots). * RFC 1035 specifies a maximum of 63 characters per label. * @default 63 */ maxDomainLabelLength?: number; } /** * Validates whether a given string is a valid email address. * * This function performs comprehensive email validation according to RFC 5322 standards, * handling all edge cases including: * - Local part validation (before @): allows letters, numbers, and special chars like .!#$%&'*+-/=?^_`{|}~ * - Quoted strings in local part (e.g., "john..doe"@example.com) * - Domain validation: proper domain structure with valid TLD * - IP address domains: [IPv4] and [IPv6] formats * - International domains: IDN (Internationalized Domain Names) * - Configurable length constraints with sensible defaults * - Edge cases: consecutive dots, leading/trailing dots, escaped characters * * @param email - The string to validate as an email address * @param options - Optional configuration for validation constraints * @returns true if the string is a valid email address, false otherwise * * @example * isEmail("user@example.com") // true * isEmail("user.name+tag@example.co.uk") // true * isEmail("invalid@") // false * isEmail("@invalid.com") // false * * // Custom length limits * isEmail("very.long.email@domain.com", { maxTotalLength: 100 }) // true if under 100 chars */ export declare function isEmail(email: unknown, options?: IsEmailOptions): boolean;