tenara-ui-components 0.3.72 → 0.3.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.esm.css +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/emailValidation.d.ts +83 -0
- package/dist/utils/emailValidation.d.ts.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Email Validation Utility
|
|
3
|
+
*
|
|
4
|
+
* Framework-agnostic utility for detecting non-work email addresses.
|
|
5
|
+
* Provides a configurable blocklist of personal, disposable, and ISP email domains.
|
|
6
|
+
*/
|
|
7
|
+
/** Default list of blocked email domains (personal, disposable, and ISP providers) */
|
|
8
|
+
export declare const BLOCKED_EMAIL_DOMAINS: string[];
|
|
9
|
+
/** Options for configuring email blocklist validation */
|
|
10
|
+
export interface EmailBlocklistOptions {
|
|
11
|
+
/** Additional domains to block on top of the default list */
|
|
12
|
+
additionalDomains?: string[];
|
|
13
|
+
/** Domains to allow even if they appear in the default blocklist */
|
|
14
|
+
allowedDomains?: string[];
|
|
15
|
+
/** Completely replace the default blocklist with a custom one */
|
|
16
|
+
customBlocklist?: string[];
|
|
17
|
+
}
|
|
18
|
+
/** Result returned by email validation functions */
|
|
19
|
+
export interface EmailValidationResult {
|
|
20
|
+
valid: boolean;
|
|
21
|
+
reason?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Validates basic email format (not exhaustive — use in combination with
|
|
25
|
+
* your form library's built-in email validation for full coverage).
|
|
26
|
+
*
|
|
27
|
+
* Checks:
|
|
28
|
+
* - Contains exactly one `@`
|
|
29
|
+
* - Local part is non-empty
|
|
30
|
+
* - Domain contains at least one dot
|
|
31
|
+
* - No spaces
|
|
32
|
+
*/
|
|
33
|
+
export declare function isValidEmail(email: string): EmailValidationResult;
|
|
34
|
+
/**
|
|
35
|
+
* Checks whether an email address belongs to a blocked domain
|
|
36
|
+
* (personal, disposable, or ISP provider).
|
|
37
|
+
*
|
|
38
|
+
* @param email - The email address to check
|
|
39
|
+
* @param options - Optional configuration to extend/override the blocklist
|
|
40
|
+
* @returns `EmailValidationResult` with `valid: true` if the email is NOT blocked
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* // Basic usage
|
|
45
|
+
* const result = isBlockedEmail('user@gmail.com');
|
|
46
|
+
* // { valid: false, reason: 'Please use your work email address' }
|
|
47
|
+
*
|
|
48
|
+
* // With additional blocked domains
|
|
49
|
+
* const result = isBlockedEmail('user@custom-free.com', {
|
|
50
|
+
* additionalDomains: ['custom-free.com'],
|
|
51
|
+
* });
|
|
52
|
+
*
|
|
53
|
+
* // Allowing a normally-blocked domain
|
|
54
|
+
* const result = isBlockedEmail('user@gmail.com', {
|
|
55
|
+
* allowedDomains: ['gmail.com'],
|
|
56
|
+
* });
|
|
57
|
+
* // { valid: true }
|
|
58
|
+
*
|
|
59
|
+
* // Replacing the entire blocklist
|
|
60
|
+
* const result = isBlockedEmail('user@only-block-this.com', {
|
|
61
|
+
* customBlocklist: ['only-block-this.com'],
|
|
62
|
+
* });
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare function isBlockedEmail(email: string, options?: EmailBlocklistOptions): EmailValidationResult;
|
|
66
|
+
/**
|
|
67
|
+
* Convenience function that runs both format validation and blocklist check.
|
|
68
|
+
*
|
|
69
|
+
* @param email - The email address to validate
|
|
70
|
+
* @param options - Optional blocklist configuration
|
|
71
|
+
* @returns `EmailValidationResult` — fails on the first issue found
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* const result = validateWorkEmail('user@gmail.com');
|
|
76
|
+
* // { valid: false, reason: 'Please use your work email address' }
|
|
77
|
+
*
|
|
78
|
+
* const result = validateWorkEmail('user@company.com');
|
|
79
|
+
* // { valid: true }
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export declare function validateWorkEmail(email: string, options?: EmailBlocklistOptions): EmailValidationResult;
|
|
83
|
+
//# sourceMappingURL=emailValidation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emailValidation.d.ts","sourceRoot":"","sources":["../../src/utils/emailValidation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,sFAAsF;AACtF,eAAO,MAAM,qBAAqB,EAAE,MAAM,EA8EzC,CAAC;AAEF,yDAAyD;AACzD,MAAM,WAAW,qBAAqB;IACpC,6DAA6D;IAC7D,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,oEAAoE;IACpE,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,iEAAiE;IACjE,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED,oDAAoD;AACpD,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAyBD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,qBAAqB,CAiCjE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,qBAAqB,CAcpG;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,qBAAqB,CAKvG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE3G,YAAY,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC"}
|