typebox 1.1.22 → 1.1.23

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
2
  * Returns true if the value is an Email
3
- * @specification Json Schema 2020-12
3
+ * @specification ajv-formats
4
4
  */
5
5
  export declare function IsEmail(value: string): boolean;
@@ -1,29 +1,8 @@
1
- import { IsIPv4Internal } from './ipv4.mjs';
1
+ const Email = /^(?!.*\.\.)[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i;
2
2
  /**
3
3
  * Returns true if the value is an Email
4
- * @specification Json Schema 2020-12
4
+ * @specification ajv-formats
5
5
  */
6
6
  export function IsEmail(value) {
7
- const dot = value.indexOf('.');
8
- const at = value.indexOf('@');
9
- const quoted = value[0] === '"' && value[at - 1] === '"';
10
- const ipLiteral = value[at + 1] === '[' && value[value.length - 1] === ']';
11
- const ipv6 = ipLiteral && value.indexOf(':', at) !== -1;
12
- const ipv4 = ipLiteral && !ipv6 && IsIPv4Internal(value, at + 2, value.length - 1);
13
- return (at > 0 && at < value.length - 1) &&
14
- !(
15
- // .test@example.com
16
- (!quoted && dot === 0) ||
17
- // te..st@example.com
18
- (!quoted && dot !== -1 && value.indexOf('.', dot + 1) === dot + 1) ||
19
- // test.@example.com
20
- (dot !== -1 && value.indexOf('@', dot) === dot + 1) ||
21
- // joe bloggs@example.com
22
- (!quoted && value.indexOf(' ') !== -1) ||
23
- // user1@oceania.org, user2@oceania.org
24
- (value.indexOf(',') !== -1) ||
25
- // joe.bloggs@[127.0.0.300]
26
- (ipLiteral && !ipv4 && !ipv6) ||
27
- // joe.bloggs@invalid=domain.com
28
- (value.indexOf('=', at) !== -1));
7
+ return Email.test(value);
29
8
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
2
  * Returns true if the value is an IdnEmail
3
- * @specification Json Schema 2020-12
3
+ * @specification ajv-formats (unicode-extension)
4
4
  */
5
5
  export declare function IsIdnEmail(value: string): boolean;
@@ -1,8 +1,8 @@
1
- import { IsEmail } from './email.mjs';
1
+ const IdnEmail = /^(?!.*\.\.)[\p{L}\p{N}!#$%&'*+/=?^_`{|}~-]+(?:\.[\p{L}\p{N}!#$%&'*+/=?^_`{|}~-]+)*@[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,61}[\p{L}\p{N}])?(?:\.[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,61}[\p{L}\p{N}])?)*$/iu;
2
2
  /**
3
3
  * Returns true if the value is an IdnEmail
4
- * @specification Json Schema 2020-12
4
+ * @specification ajv-formats (unicode-extension)
5
5
  */
6
6
  export function IsIdnEmail(value) {
7
- return IsEmail(value);
7
+ return IdnEmail.test(value);
8
8
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "typebox",
3
3
  "description": "Json Schema Type Builder with Static Type Resolution for TypeScript",
4
- "version": "1.1.22",
4
+ "version": "1.1.23",
5
5
  "keywords": [
6
6
  "typescript",
7
7
  "jsonschema"
@@ -16,21 +16,29 @@
16
16
  "types": "./build/index.d.mts",
17
17
  "module": "./build/index.mjs",
18
18
  "exports": {
19
- "./guard": {
20
- "import": "./build/guard/index.mjs",
21
- "default": "./build/guard/index.mjs"
19
+ "./system": {
20
+ "import": "./build/system/index.mjs",
21
+ "default": "./build/system/index.mjs"
22
+ },
23
+ "./compile": {
24
+ "import": "./build/compile/index.mjs",
25
+ "default": "./build/compile/index.mjs"
26
+ },
27
+ "./value": {
28
+ "import": "./build/value/index.mjs",
29
+ "default": "./build/value/index.mjs"
22
30
  },
23
31
  "./error": {
24
32
  "import": "./build/error/index.mjs",
25
33
  "default": "./build/error/index.mjs"
26
34
  },
27
- "./compile": {
28
- "import": "./build/compile/index.mjs",
29
- "default": "./build/compile/index.mjs"
35
+ "./guard": {
36
+ "import": "./build/guard/index.mjs",
37
+ "default": "./build/guard/index.mjs"
30
38
  },
31
- "./system": {
32
- "import": "./build/system/index.mjs",
33
- "default": "./build/system/index.mjs"
39
+ "./schema": {
40
+ "import": "./build/schema/index.mjs",
41
+ "default": "./build/schema/index.mjs"
34
42
  },
35
43
  "./format": {
36
44
  "import": "./build/format/index.mjs",
@@ -40,14 +48,6 @@
40
48
  "import": "./build/type/index.mjs",
41
49
  "default": "./build/type/index.mjs"
42
50
  },
43
- "./schema": {
44
- "import": "./build/schema/index.mjs",
45
- "default": "./build/schema/index.mjs"
46
- },
47
- "./value": {
48
- "import": "./build/value/index.mjs",
49
- "default": "./build/value/index.mjs"
50
- },
51
51
  ".": {
52
52
  "import": "./build/index.mjs",
53
53
  "default": "./build/index.mjs"
@@ -55,17 +55,23 @@
55
55
  },
56
56
  "typesVersions": {
57
57
  "*": {
58
- "guard": [
59
- "./build/guard/index.d.mts"
58
+ "system": [
59
+ "./build/system/index.d.mts"
60
+ ],
61
+ "compile": [
62
+ "./build/compile/index.d.mts"
63
+ ],
64
+ "value": [
65
+ "./build/value/index.d.mts"
60
66
  ],
61
67
  "error": [
62
68
  "./build/error/index.d.mts"
63
69
  ],
64
- "compile": [
65
- "./build/compile/index.d.mts"
70
+ "guard": [
71
+ "./build/guard/index.d.mts"
66
72
  ],
67
- "system": [
68
- "./build/system/index.d.mts"
73
+ "schema": [
74
+ "./build/schema/index.d.mts"
69
75
  ],
70
76
  "format": [
71
77
  "./build/format/index.d.mts"
@@ -73,12 +79,6 @@
73
79
  "type": [
74
80
  "./build/type/index.d.mts"
75
81
  ],
76
- "schema": [
77
- "./build/schema/index.d.mts"
78
- ],
79
- "value": [
80
- "./build/value/index.d.mts"
81
- ],
82
82
  ".": [
83
83
  "./build/index.d.mts"
84
84
  ]