inferred-types 0.50.19 → 0.50.20
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/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/inferred-types/tsconfig.tsbuildinfo +1 -1
- package/dist/runtime/tsconfig.tsbuildinfo +1 -1
- package/dist/runtime/type-guards/isEmail.d.ts +1 -0
- package/dist/runtime/type-guards/isEmail.d.ts.map +1 -1
- package/dist/runtime/type-guards/isEmail.js +2 -1
- package/package.json +1 -1
|
@@ -8,6 +8,7 @@ import { Email } from "src/types/index";
|
|
|
8
8
|
* 1. that leads with alphabetic char
|
|
9
9
|
* 2. has a `@` character
|
|
10
10
|
* 3. has at least one `.` char after the `@`
|
|
11
|
+
* 4. top-level domain has at least 2 characters
|
|
11
12
|
*/
|
|
12
13
|
export declare const isEmail: (val: unknown) => val is Email;
|
|
13
14
|
//# sourceMappingURL=isEmail.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isEmail.d.ts","sourceRoot":"","sources":["../../../src/runtime/type-guards/isEmail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAIvC
|
|
1
|
+
{"version":3,"file":"isEmail.d.ts","sourceRoot":"","sources":["../../../src/runtime/type-guards/isEmail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAIvC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,OAAO,QAAS,OAAO,KAAG,GAAG,IAAI,KAe7C,CAAA"}
|
|
@@ -9,6 +9,7 @@ import { LOWER_ALPHA_CHARS } from "src/constants/Alpha";
|
|
|
9
9
|
* 1. that leads with alphabetic char
|
|
10
10
|
* 2. has a `@` character
|
|
11
11
|
* 3. has at least one `.` char after the `@`
|
|
12
|
+
* 4. top-level domain has at least 2 characters
|
|
12
13
|
*/
|
|
13
14
|
export const isEmail = (val) => {
|
|
14
15
|
if (!isString(val)) {
|
|
@@ -16,7 +17,7 @@ export const isEmail = (val) => {
|
|
|
16
17
|
}
|
|
17
18
|
const parts = val?.split("@");
|
|
18
19
|
const domain = parts[1]?.split(".");
|
|
19
|
-
const tld = domain.pop();
|
|
20
|
+
const tld = domain ? domain.pop() : "";
|
|
20
21
|
const firstChar = val[0].toLowerCase();
|
|
21
22
|
return isString(val) && (LOWER_ALPHA_CHARS.includes(firstChar) &&
|
|
22
23
|
parts.length === 2 &&
|