@sinclair/typebox 0.25.24 → 0.26.0-dev.1
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 +10 -5
- package/compiler/compiler.js +161 -123
- package/errors/errors.d.ts +56 -46
- package/errors/errors.js +234 -153
- package/package.json +1 -6
- package/readme.md +294 -207
- package/system/system.d.ts +9 -6
- package/system/system.js +17 -17
- package/typebox.d.ts +388 -162
- package/typebox.js +1716 -229
- package/value/cast.d.ts +2 -2
- package/value/cast.js +121 -188
- package/value/check.d.ts +1 -1
- package/value/check.js +156 -111
- package/value/convert.d.ts +13 -0
- package/value/convert.js +345 -0
- package/value/create.d.ts +6 -2
- package/value/create.js +149 -97
- package/{hash → value}/hash.js +39 -14
- package/value/index.d.ts +1 -0
- package/value/index.js +3 -1
- package/value/value.d.ts +2 -8
- package/value/value.js +20 -14
- package/conditional/conditional.d.ts +0 -17
- package/conditional/conditional.js +0 -91
- package/conditional/index.d.ts +0 -2
- package/conditional/index.js +0 -45
- package/conditional/structural.d.ts +0 -11
- package/conditional/structural.js +0 -685
- package/custom/custom.d.ts +0 -12
- package/custom/custom.js +0 -55
- package/custom/index.d.ts +0 -1
- package/custom/index.js +0 -44
- package/format/format.d.ts +0 -12
- package/format/format.js +0 -55
- package/format/index.d.ts +0 -1
- package/format/index.js +0 -44
- package/guard/extends.d.ts +0 -10
- package/guard/extends.js +0 -50
- package/guard/guard.d.ts +0 -60
- package/guard/guard.js +0 -440
- package/guard/index.d.ts +0 -2
- package/guard/index.js +0 -45
- package/hash/index.d.ts +0 -1
- package/hash/index.js +0 -44
- /package/{hash → value}/hash.d.ts +0 -0
package/system/system.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as Types from '../typebox';
|
|
1
2
|
export declare class TypeSystemDuplicateTypeKind extends Error {
|
|
2
3
|
constructor(kind: string);
|
|
3
4
|
}
|
|
@@ -6,12 +7,14 @@ export declare class TypeSystemDuplicateFormat extends Error {
|
|
|
6
7
|
}
|
|
7
8
|
/** Creates user defined types and formats and provides overrides for value checking behaviours */
|
|
8
9
|
export declare namespace TypeSystem {
|
|
9
|
-
/** Sets whether arrays should be treated as
|
|
10
|
+
/** Sets whether arrays should be treated as a kind of objects. The default is `false` */
|
|
10
11
|
let AllowArrayObjects: boolean;
|
|
11
|
-
/** Sets whether
|
|
12
|
+
/** Sets whether `NaN` or `Infinity` should be treated as valid numeric values. The default is `false` */
|
|
12
13
|
let AllowNaN: boolean;
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
/** Creates a
|
|
16
|
-
function
|
|
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;
|
|
17
20
|
}
|
package/system/system.js
CHANGED
|
@@ -28,9 +28,7 @@ THE SOFTWARE.
|
|
|
28
28
|
---------------------------------------------------------------------------*/
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
30
|
exports.TypeSystem = exports.TypeSystemDuplicateFormat = exports.TypeSystemDuplicateTypeKind = void 0;
|
|
31
|
-
const
|
|
32
|
-
const index_1 = require("../custom/index");
|
|
33
|
-
const index_2 = require("../format/index");
|
|
31
|
+
const Types = require("../typebox");
|
|
34
32
|
class TypeSystemDuplicateTypeKind extends Error {
|
|
35
33
|
constructor(kind) {
|
|
36
34
|
super(`Duplicate kind '${kind}' detected`);
|
|
@@ -46,24 +44,26 @@ exports.TypeSystemDuplicateFormat = TypeSystemDuplicateFormat;
|
|
|
46
44
|
/** Creates user defined types and formats and provides overrides for value checking behaviours */
|
|
47
45
|
var TypeSystem;
|
|
48
46
|
(function (TypeSystem) {
|
|
49
|
-
/** Sets whether arrays should be treated as
|
|
47
|
+
/** Sets whether arrays should be treated as a kind of objects. The default is `false` */
|
|
50
48
|
TypeSystem.AllowArrayObjects = false;
|
|
51
|
-
/** Sets whether
|
|
49
|
+
/** Sets whether `NaN` or `Infinity` should be treated as valid numeric values. The default is `false` */
|
|
52
50
|
TypeSystem.AllowNaN = false;
|
|
53
|
-
/**
|
|
54
|
-
|
|
55
|
-
|
|
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
56
|
throw new TypeSystemDuplicateTypeKind(kind);
|
|
57
|
-
|
|
58
|
-
return (options = {}) =>
|
|
57
|
+
Types.TypeRegistry.Set(kind, check);
|
|
58
|
+
return (options = {}) => Types.Type.Unsafe({ ...options, [Types.Kind]: kind });
|
|
59
59
|
}
|
|
60
|
-
TypeSystem.
|
|
61
|
-
/** Creates a
|
|
62
|
-
function
|
|
63
|
-
if (
|
|
60
|
+
TypeSystem.Type = Type;
|
|
61
|
+
/** Creates a new string format */
|
|
62
|
+
function Format(format, check) {
|
|
63
|
+
if (Types.FormatRegistry.Has(format))
|
|
64
64
|
throw new TypeSystemDuplicateFormat(format);
|
|
65
|
-
|
|
66
|
-
return
|
|
65
|
+
Types.FormatRegistry.Set(format, check);
|
|
66
|
+
return format;
|
|
67
67
|
}
|
|
68
|
-
TypeSystem.
|
|
68
|
+
TypeSystem.Format = Format;
|
|
69
69
|
})(TypeSystem = exports.TypeSystem || (exports.TypeSystem = {}));
|