@sinclair/typebox 0.26.0-dev.1 → 0.26.0-dev.3
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/compiler/compiler.d.ts +33 -33
- package/compiler/compiler.js +536 -536
- package/compiler/index.d.ts +2 -2
- package/compiler/index.js +47 -47
- package/errors/errors.d.ts +84 -77
- package/errors/errors.js +570 -553
- package/errors/index.d.ts +1 -1
- package/errors/index.js +44 -44
- package/package.json +2 -2
- package/readme.md +4 -10
- package/system/index.d.ts +1 -1
- package/system/index.js +44 -44
- package/system/system.d.ts +20 -20
- package/system/system.js +69 -69
- package/typebox.d.ts +648 -648
- package/typebox.js +1881 -1875
- package/value/cast.d.ts +26 -26
- package/value/cast.js +348 -348
- package/value/check.d.ts +8 -8
- package/value/check.js +450 -450
- package/value/clone.d.ts +3 -3
- package/value/clone.js +71 -71
- package/value/convert.d.ts +13 -13
- package/value/convert.js +345 -345
- package/value/create.d.ts +18 -18
- package/value/create.js +430 -430
- package/value/delta.d.ts +43 -43
- package/value/delta.js +204 -204
- package/value/equal.d.ts +3 -3
- package/value/equal.js +80 -80
- package/value/hash.d.ts +8 -8
- package/value/hash.js +208 -208
- package/value/index.d.ts +5 -5
- package/value/index.js +56 -55
- package/value/is.d.ts +11 -11
- package/value/is.js +53 -53
- package/value/pointer.d.ts +24 -24
- package/value/pointer.js +142 -142
- package/value/value.d.ts +26 -26
- package/value/value.js +93 -93
package/errors/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './errors';
|
|
1
|
+
export * from './errors';
|
package/errors/index.js
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*--------------------------------------------------------------------------
|
|
3
|
-
|
|
4
|
-
@sinclair/typebox/errors
|
|
5
|
-
|
|
6
|
-
The MIT License (MIT)
|
|
7
|
-
|
|
8
|
-
Copyright (c) 2017-2023 Haydn Paterson (sinclair) <haydn.developer@gmail.com>
|
|
9
|
-
|
|
10
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
-
in the Software without restriction, including without limitation the rights
|
|
13
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
-
furnished to do so, subject to the following conditions:
|
|
16
|
-
|
|
17
|
-
The above copyright notice and this permission notice shall be included in
|
|
18
|
-
all copies or substantial portions of the Software.
|
|
19
|
-
|
|
20
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
26
|
-
THE SOFTWARE.
|
|
27
|
-
|
|
28
|
-
---------------------------------------------------------------------------*/
|
|
29
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
30
|
-
if (k2 === undefined) k2 = k;
|
|
31
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
32
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
33
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
34
|
-
}
|
|
35
|
-
Object.defineProperty(o, k2, desc);
|
|
36
|
-
}) : (function(o, m, k, k2) {
|
|
37
|
-
if (k2 === undefined) k2 = k;
|
|
38
|
-
o[k2] = m[k];
|
|
39
|
-
}));
|
|
40
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
41
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
42
|
-
};
|
|
43
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
-
__exportStar(require("./errors"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
/*--------------------------------------------------------------------------
|
|
3
|
+
|
|
4
|
+
@sinclair/typebox/errors
|
|
5
|
+
|
|
6
|
+
The MIT License (MIT)
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2017-2023 Haydn Paterson (sinclair) <haydn.developer@gmail.com>
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in
|
|
18
|
+
all copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
26
|
+
THE SOFTWARE.
|
|
27
|
+
|
|
28
|
+
---------------------------------------------------------------------------*/
|
|
29
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
30
|
+
if (k2 === undefined) k2 = k;
|
|
31
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
32
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
33
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
34
|
+
}
|
|
35
|
+
Object.defineProperty(o, k2, desc);
|
|
36
|
+
}) : (function(o, m, k, k2) {
|
|
37
|
+
if (k2 === undefined) k2 = k;
|
|
38
|
+
o[k2] = m[k];
|
|
39
|
+
}));
|
|
40
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
41
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
42
|
+
};
|
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
+
__exportStar(require("./errors"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sinclair/typebox",
|
|
3
|
-
"version": "0.26.0-dev.
|
|
3
|
+
"version": "0.26.0-dev.3",
|
|
4
4
|
"description": "JSONSchema Type Builder with Static Type Resolution for TypeScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -42,6 +42,6 @@
|
|
|
42
42
|
"chai": "^4.3.6",
|
|
43
43
|
"mocha": "^9.2.2",
|
|
44
44
|
"prettier": "^2.7.1",
|
|
45
|
-
"typescript": "^
|
|
45
|
+
"typescript": "^5.0.2"
|
|
46
46
|
}
|
|
47
47
|
}
|
package/readme.md
CHANGED
|
@@ -343,13 +343,7 @@ The following table lists the Standard TypeBox types. These types are fully comp
|
|
|
343
343
|
│ │ │ │
|
|
344
344
|
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
|
|
345
345
|
│ const T = Type.Never() │ type T = never │ const T = { │
|
|
346
|
-
│ │ │
|
|
347
|
-
│ │ │ type: 'boolean', │
|
|
348
|
-
│ │ │ const: false │
|
|
349
|
-
│ │ │ }, { │
|
|
350
|
-
│ │ │ type: 'boolean', │
|
|
351
|
-
│ │ │ const: true │
|
|
352
|
-
│ │ │ }] │
|
|
346
|
+
│ │ │ not: {} │
|
|
353
347
|
│ │ │ } │
|
|
354
348
|
│ │ │ │
|
|
355
349
|
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
|
|
@@ -586,9 +580,9 @@ TypeBox provides property modifier types that allow properties to be mapped with
|
|
|
586
580
|
│ const T = Type.Object({ │ type T = { │ const T = { │
|
|
587
581
|
│ name: Type.Optional( │ name?: string │ type: 'object', │
|
|
588
582
|
│ Type.String() │ } │ properties: { │
|
|
589
|
-
│ ) │ │
|
|
590
|
-
│ }) │ │
|
|
591
|
-
│ │ │
|
|
583
|
+
│ ) │ │ name: { │
|
|
584
|
+
│ }) │ │ type: 'string' │
|
|
585
|
+
│ │ │ } │
|
|
592
586
|
│ │ │ } │
|
|
593
587
|
│ │ │ } │
|
|
594
588
|
│ │ │ │
|
package/system/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './system';
|
|
1
|
+
export * from './system';
|
package/system/index.js
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*--------------------------------------------------------------------------
|
|
3
|
-
|
|
4
|
-
@sinclair/typebox/system
|
|
5
|
-
|
|
6
|
-
The MIT License (MIT)
|
|
7
|
-
|
|
8
|
-
Copyright (c) 2017-2023 Haydn Paterson (sinclair) <haydn.developer@gmail.com>
|
|
9
|
-
|
|
10
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
-
in the Software without restriction, including without limitation the rights
|
|
13
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
-
furnished to do so, subject to the following conditions:
|
|
16
|
-
|
|
17
|
-
The above copyright notice and this permission notice shall be included in
|
|
18
|
-
all copies or substantial portions of the Software.
|
|
19
|
-
|
|
20
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
26
|
-
THE SOFTWARE.
|
|
27
|
-
|
|
28
|
-
---------------------------------------------------------------------------*/
|
|
29
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
30
|
-
if (k2 === undefined) k2 = k;
|
|
31
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
32
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
33
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
34
|
-
}
|
|
35
|
-
Object.defineProperty(o, k2, desc);
|
|
36
|
-
}) : (function(o, m, k, k2) {
|
|
37
|
-
if (k2 === undefined) k2 = k;
|
|
38
|
-
o[k2] = m[k];
|
|
39
|
-
}));
|
|
40
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
41
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
42
|
-
};
|
|
43
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
-
__exportStar(require("./system"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
/*--------------------------------------------------------------------------
|
|
3
|
+
|
|
4
|
+
@sinclair/typebox/system
|
|
5
|
+
|
|
6
|
+
The MIT License (MIT)
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2017-2023 Haydn Paterson (sinclair) <haydn.developer@gmail.com>
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in
|
|
18
|
+
all copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
26
|
+
THE SOFTWARE.
|
|
27
|
+
|
|
28
|
+
---------------------------------------------------------------------------*/
|
|
29
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
30
|
+
if (k2 === undefined) k2 = k;
|
|
31
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
32
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
33
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
34
|
+
}
|
|
35
|
+
Object.defineProperty(o, k2, desc);
|
|
36
|
+
}) : (function(o, m, k, k2) {
|
|
37
|
+
if (k2 === undefined) k2 = k;
|
|
38
|
+
o[k2] = m[k];
|
|
39
|
+
}));
|
|
40
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
41
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
42
|
+
};
|
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
+
__exportStar(require("./system"), exports);
|
package/system/system.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import * as Types from '../typebox';
|
|
2
|
-
export declare class TypeSystemDuplicateTypeKind extends Error {
|
|
3
|
-
constructor(kind: string);
|
|
4
|
-
}
|
|
5
|
-
export declare class TypeSystemDuplicateFormat extends Error {
|
|
6
|
-
constructor(kind: string);
|
|
7
|
-
}
|
|
8
|
-
/** Creates user defined types and formats and provides overrides for value checking behaviours */
|
|
9
|
-
export declare namespace TypeSystem {
|
|
10
|
-
/** Sets whether arrays should be treated as a kind of objects. The default is `false` */
|
|
11
|
-
let AllowArrayObjects: boolean;
|
|
12
|
-
/** Sets whether `NaN` or `Infinity` should be treated as valid numeric values. The default is `false` */
|
|
13
|
-
let AllowNaN: boolean;
|
|
14
|
-
/** Sets whether `null` should validate for void types. The default is `false` */
|
|
15
|
-
let AllowVoidNull: boolean;
|
|
16
|
-
/** Creates a new type */
|
|
17
|
-
function Type<Type, Options = object>(kind: string, check: (options: Options, value: unknown) => boolean): (options?: Partial<Options>) => Types.TUnsafe<Type>;
|
|
18
|
-
/** Creates a new string format */
|
|
19
|
-
function Format<F extends string>(format: F, check: (value: string) => boolean): F;
|
|
20
|
-
}
|
|
1
|
+
import * as Types from '../typebox';
|
|
2
|
+
export declare class TypeSystemDuplicateTypeKind extends Error {
|
|
3
|
+
constructor(kind: string);
|
|
4
|
+
}
|
|
5
|
+
export declare class TypeSystemDuplicateFormat extends Error {
|
|
6
|
+
constructor(kind: string);
|
|
7
|
+
}
|
|
8
|
+
/** Creates user defined types and formats and provides overrides for value checking behaviours */
|
|
9
|
+
export declare namespace TypeSystem {
|
|
10
|
+
/** Sets whether arrays should be treated as a kind of objects. The default is `false` */
|
|
11
|
+
let AllowArrayObjects: boolean;
|
|
12
|
+
/** Sets whether `NaN` or `Infinity` should be treated as valid numeric values. The default is `false` */
|
|
13
|
+
let AllowNaN: boolean;
|
|
14
|
+
/** Sets whether `null` should validate for void types. The default is `false` */
|
|
15
|
+
let AllowVoidNull: boolean;
|
|
16
|
+
/** Creates a new type */
|
|
17
|
+
function Type<Type, Options = object>(kind: string, check: (options: Options, value: unknown) => boolean): (options?: Partial<Options>) => Types.TUnsafe<Type>;
|
|
18
|
+
/** Creates a new string format */
|
|
19
|
+
function Format<F extends string>(format: F, check: (value: string) => boolean): F;
|
|
20
|
+
}
|
package/system/system.js
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*--------------------------------------------------------------------------
|
|
3
|
-
|
|
4
|
-
@sinclair/typebox/system
|
|
5
|
-
|
|
6
|
-
The MIT License (MIT)
|
|
7
|
-
|
|
8
|
-
Copyright (c) 2017-2023 Haydn Paterson (sinclair) <haydn.developer@gmail.com>
|
|
9
|
-
|
|
10
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
-
in the Software without restriction, including without limitation the rights
|
|
13
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
-
furnished to do so, subject to the following conditions:
|
|
16
|
-
|
|
17
|
-
The above copyright notice and this permission notice shall be included in
|
|
18
|
-
all copies or substantial portions of the Software.
|
|
19
|
-
|
|
20
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
26
|
-
THE SOFTWARE.
|
|
27
|
-
|
|
28
|
-
---------------------------------------------------------------------------*/
|
|
29
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.TypeSystem = exports.TypeSystemDuplicateFormat = exports.TypeSystemDuplicateTypeKind = void 0;
|
|
31
|
-
const Types = require("../typebox");
|
|
32
|
-
class TypeSystemDuplicateTypeKind extends Error {
|
|
33
|
-
constructor(kind) {
|
|
34
|
-
super(`Duplicate kind '${kind}' detected`);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.TypeSystemDuplicateTypeKind = TypeSystemDuplicateTypeKind;
|
|
38
|
-
class TypeSystemDuplicateFormat extends Error {
|
|
39
|
-
constructor(kind) {
|
|
40
|
-
super(`Duplicate format '${kind}' detected`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.TypeSystemDuplicateFormat = TypeSystemDuplicateFormat;
|
|
44
|
-
/** Creates user defined types and formats and provides overrides for value checking behaviours */
|
|
45
|
-
var TypeSystem;
|
|
46
|
-
(function (TypeSystem) {
|
|
47
|
-
/** Sets whether arrays should be treated as a kind of objects. The default is `false` */
|
|
48
|
-
TypeSystem.AllowArrayObjects = false;
|
|
49
|
-
/** Sets whether `NaN` or `Infinity` should be treated as valid numeric values. The default is `false` */
|
|
50
|
-
TypeSystem.AllowNaN = false;
|
|
51
|
-
/** Sets whether `null` should validate for void types. The default is `false` */
|
|
52
|
-
TypeSystem.AllowVoidNull = false;
|
|
53
|
-
/** Creates a new type */
|
|
54
|
-
function Type(kind, check) {
|
|
55
|
-
if (Types.TypeRegistry.Has(kind))
|
|
56
|
-
throw new TypeSystemDuplicateTypeKind(kind);
|
|
57
|
-
Types.TypeRegistry.Set(kind, check);
|
|
58
|
-
return (options = {}) => Types.Type.Unsafe({ ...options, [Types.Kind]: kind });
|
|
59
|
-
}
|
|
60
|
-
TypeSystem.Type = Type;
|
|
61
|
-
/** Creates a new string format */
|
|
62
|
-
function Format(format, check) {
|
|
63
|
-
if (Types.FormatRegistry.Has(format))
|
|
64
|
-
throw new TypeSystemDuplicateFormat(format);
|
|
65
|
-
Types.FormatRegistry.Set(format, check);
|
|
66
|
-
return format;
|
|
67
|
-
}
|
|
68
|
-
TypeSystem.Format = Format;
|
|
69
|
-
})(TypeSystem = exports.TypeSystem || (exports.TypeSystem = {}));
|
|
1
|
+
"use strict";
|
|
2
|
+
/*--------------------------------------------------------------------------
|
|
3
|
+
|
|
4
|
+
@sinclair/typebox/system
|
|
5
|
+
|
|
6
|
+
The MIT License (MIT)
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2017-2023 Haydn Paterson (sinclair) <haydn.developer@gmail.com>
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in
|
|
18
|
+
all copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
26
|
+
THE SOFTWARE.
|
|
27
|
+
|
|
28
|
+
---------------------------------------------------------------------------*/
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.TypeSystem = exports.TypeSystemDuplicateFormat = exports.TypeSystemDuplicateTypeKind = void 0;
|
|
31
|
+
const Types = require("../typebox");
|
|
32
|
+
class TypeSystemDuplicateTypeKind extends Error {
|
|
33
|
+
constructor(kind) {
|
|
34
|
+
super(`Duplicate kind '${kind}' detected`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.TypeSystemDuplicateTypeKind = TypeSystemDuplicateTypeKind;
|
|
38
|
+
class TypeSystemDuplicateFormat extends Error {
|
|
39
|
+
constructor(kind) {
|
|
40
|
+
super(`Duplicate format '${kind}' detected`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.TypeSystemDuplicateFormat = TypeSystemDuplicateFormat;
|
|
44
|
+
/** Creates user defined types and formats and provides overrides for value checking behaviours */
|
|
45
|
+
var TypeSystem;
|
|
46
|
+
(function (TypeSystem) {
|
|
47
|
+
/** Sets whether arrays should be treated as a kind of objects. The default is `false` */
|
|
48
|
+
TypeSystem.AllowArrayObjects = false;
|
|
49
|
+
/** Sets whether `NaN` or `Infinity` should be treated as valid numeric values. The default is `false` */
|
|
50
|
+
TypeSystem.AllowNaN = false;
|
|
51
|
+
/** Sets whether `null` should validate for void types. The default is `false` */
|
|
52
|
+
TypeSystem.AllowVoidNull = false;
|
|
53
|
+
/** Creates a new type */
|
|
54
|
+
function Type(kind, check) {
|
|
55
|
+
if (Types.TypeRegistry.Has(kind))
|
|
56
|
+
throw new TypeSystemDuplicateTypeKind(kind);
|
|
57
|
+
Types.TypeRegistry.Set(kind, check);
|
|
58
|
+
return (options = {}) => Types.Type.Unsafe({ ...options, [Types.Kind]: kind });
|
|
59
|
+
}
|
|
60
|
+
TypeSystem.Type = Type;
|
|
61
|
+
/** Creates a new string format */
|
|
62
|
+
function Format(format, check) {
|
|
63
|
+
if (Types.FormatRegistry.Has(format))
|
|
64
|
+
throw new TypeSystemDuplicateFormat(format);
|
|
65
|
+
Types.FormatRegistry.Set(format, check);
|
|
66
|
+
return format;
|
|
67
|
+
}
|
|
68
|
+
TypeSystem.Format = Format;
|
|
69
|
+
})(TypeSystem = exports.TypeSystem || (exports.TypeSystem = {}));
|