typebox 1.0.0-rc → 1.0.0
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/package.json +1 -1
- package/readme.md +10 -10
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -50,7 +50,7 @@ type T = Static<typeof T> // type T = {
|
|
|
50
50
|
|
|
51
51
|
TypeBox is a runtime type system that creates in-memory Json Schema objects that infer as TypeScript types. The schemas produced by this library are designed to match the static type checking rules of the TypeScript compiler. TypeBox offers a unified type that can be statically checked by TypeScript and runtime checked with Json Schema.
|
|
52
52
|
|
|
53
|
-
TypeBox is designed to bring TypeScript level programmability to Json Schema
|
|
53
|
+
TypeBox is designed to bring TypeScript level programmability to Json Schema. It is also designed to be a high performance validation solution for JavaScript. It can be used as a simple tool to build up complex schema or integrated into REST and RPC services to help validate data received over the wire.
|
|
54
54
|
|
|
55
55
|
License MIT
|
|
56
56
|
|
|
@@ -67,15 +67,15 @@ License MIT
|
|
|
67
67
|
|
|
68
68
|
## Docs
|
|
69
69
|
|
|
70
|
-
Full documentation for TypeBox can be found on the
|
|
70
|
+
Full documentation for TypeBox can be found on the website.
|
|
71
71
|
|
|
72
|
-
[
|
|
72
|
+
[Documentation](https://sinclairzx81.github.io/typebox/)
|
|
73
73
|
|
|
74
74
|
<a name="Type"></a>
|
|
75
75
|
|
|
76
76
|
## Type
|
|
77
77
|
|
|
78
|
-
[Documentation](
|
|
78
|
+
[Documentation](https://sinclairzx81.github.io/typebox/#/docs/type/overview) | [Example](https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAFQJ5gKYBo4G84xauAZRgEMZgBjOAXzgDMoIQ4ByPNAIwgA8WAoPhQgA7AM7wEcALyJ8AOgDyHAFaoKMABQ44O3Xv0HDAeiNwhYidOx8d3AFyy0cgHIBXEB1RQNASkyGAwICTXXZUBxYIFTUYFnQbOCQHZCc3Dy9ffyDsoJCdKFQAR1dgAoATBwBtFl5MFiQ41gAvFgBdeJ0m5Pk0z28fHMHAvLgwRjRYYFRRByw+agGhpeW9EdtZ3HwI4Xc+lhoOlaPltcSNsO3dr33qQ+P77NOu7E20S-SoG4SHn+NTHWo31+wJ0IUBfDCiCsxDIlAAPGEIHREAA+EGg0yQyQyObo9EjexwHYfO54n4jJJEq5QUlk+4jZ7EvpAunHMFAA)
|
|
79
79
|
|
|
80
80
|
TypeBox provides many functions to build Json Schema. Each function returns a small Json Schema fragment which maps to a corresponding TypeScript type. TypeBox uses function composition to compose schema fragments into higher order types. TypeBox provides a set of types to model Json Schema schematics. It also offers a set of extended schematics to model constructs native to TypeScript and JavaScript.
|
|
81
81
|
|
|
@@ -109,7 +109,7 @@ type T = Static<typeof T> // type T = {
|
|
|
109
109
|
|
|
110
110
|
## Script
|
|
111
111
|
|
|
112
|
-
[Documentation](
|
|
112
|
+
[Documentation](https://sinclairzx81.github.io/typebox/#/docs/script/overview) | [Example](https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAFQJ5gKYBo4G84xauAZRgEMZgBjOAXzgDMoIQ4ByPNAIwgA8WAoPhQgA7AM7wEcALyJ8AOkIUowMDAAUAAxx84cbgC44wgK4gOqKJh1wkhk2YtXdALzunzUOH2oaAlLoDAoOCQ0LCggHoIuCExCWlEAHkOACtUChgAHixrcLz8gsCogINEADl3R1zCmtqi6N1bcsrLarr2guKXQwQKhyg2jqHQ4uoAPgFY8SIE5DQFJRV1HElqTC1rAG0AaThgYTgAa1QkCDpEAF0enYu4AB8jYwAbJ+8-YY-g4qn4Qh7ktIZbKDT6fLp6HoAVWEwBEmU2vRamERLwuY3QINBw3BTQQ0NhwnhiP6yIqqPRmKxHXBrkQ+LhCL6HlJzyeaMpVLqowmfHYBEICWIZEomT5ZyIY05xT5MxkOU5WPBpXsHnujxeGIVoJxbn6apMGo5Ws6DTgtJVFn1rKNxryowEfCAA)
|
|
113
113
|
|
|
114
114
|
TypeBox is a type engine that uses Json Schema as a portable AST for runtime type representation. The Script function provides a syntax DSL to the engine and enables Json Schema to be created using native TypeScript syntax. This engine supports full type-safety for string encoded types.
|
|
115
115
|
|
|
@@ -118,7 +118,7 @@ TypeBox is a type engine that uses Json Schema as a portable AST for runtime typ
|
|
|
118
118
|
The following uses Script to create and map types.
|
|
119
119
|
|
|
120
120
|
```typescript
|
|
121
|
-
import Type from 'typebox'
|
|
121
|
+
import Type, { type Static } from 'typebox'
|
|
122
122
|
|
|
123
123
|
const T = Type.Script(`{
|
|
124
124
|
x: number,
|
|
@@ -149,7 +149,7 @@ type S = Static<typeof S> // type S = {
|
|
|
149
149
|
|
|
150
150
|
## Value
|
|
151
151
|
|
|
152
|
-
[Documentation](
|
|
152
|
+
[Documentation](https://sinclairzx81.github.io/typebox/#/docs/value/overview) | [Example](https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAFQJ5gKZwGZQiOByGFVAIwgA88AoUSWOANQEMAbAV3Sx30LVLIHoAbi3ZVKAYwgA7AM7wEcALyIiAOgDyxAFapxMABQBvSnDhkAXCrSqAcqxDFUUfQEoANCbhJLya3YdOrh6mAF4+av6Ozi6UAL4xlPz8cADCABa6ANaUEtJycACCSgwiqKrpWfoIbnCGpvUNjU1NSXCSsvAFlqQQzKiMUsUwUOyeFnAAjDXNM7Nzs57ecABMwXBhcADMcQmtAAqMUDKoOe35AELFTGxlB0eoVTV18y+mrWfw55bGpuNTrwDAfVWr9LFJ7FE1ktVkDYS8QV4wRCnGsNps4RjZgiNuCAlAdpjCVjkrFiqpyUA)
|
|
153
153
|
|
|
154
154
|
The Value module provides functions to Check and Parse JavaScript values. This module also includes functions that perform structural operations values such as Clone, Repair, Encode, Decode, Diff, Patch and Hash. This module has support for Json Schema and Standard Schema.
|
|
155
155
|
|
|
@@ -192,7 +192,7 @@ const B = Value.Parse(T, { // const B: {
|
|
|
192
192
|
|
|
193
193
|
## Compile
|
|
194
194
|
|
|
195
|
-
[Documentation](
|
|
195
|
+
[Documentation](https://sinclairzx81.github.io/typebox/#/docs/compile/overview) | [Example](https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAbzgYQuYAbApnAvnAMyjTgHIYBPMLAIwgA8B6AYzTEy1IChRJY4AKlRxES5YXXrcurAHYBneMjgBeFGw4AKIdQB0AeRoArLMxiakcK9Zu3bjRnDmKUALjgA1AIYZgAEy8YaAAeBFwAGkFDEzNQrit6dx0sXQA5AFcQGiwoTQBKSLsi4pKrB2tEwQysnPD4uAok4TTM7NyC0s6u8qtGqtba+oAvJr1qtvyuqZKeuBH+mqguXDy86fWNm3LcAD4dri5y5AALUwBrA+d4AEFVFF0T84tNjfKruGv3OghsL1k7mBQdJYeqVACMhReUNs9T6ACY6lZ5gBmZZ5A7lAAKXig8hBMggCngACE7shdNjcVhntDuo53sT3AhQe4IbT2WVHAl3LIBlBEQ13AiOezZn1eYsBSiRaKuXMeXy0TKZds7rp1UA)
|
|
196
196
|
|
|
197
197
|
The Compile module provides functions to transform types into high-performance validators. The compiler is tuned for fast compilation as well as validation. The compiler can accept both Json Schema and Standard Schema schematics however compiler optimizations are limited to Json Schema only.
|
|
198
198
|
|
|
@@ -215,7 +215,7 @@ const C = Compile(Type.Object({ // const C: Validator<{}, TO
|
|
|
215
215
|
|
|
216
216
|
// Check
|
|
217
217
|
|
|
218
|
-
const A = C.Check(
|
|
218
|
+
const A = C.Check({ // const A: boolean = true
|
|
219
219
|
x: 1,
|
|
220
220
|
y: 2,
|
|
221
221
|
z: 3
|
|
@@ -232,4 +232,4 @@ const B = C.Parse({ // const B: {
|
|
|
232
232
|
|
|
233
233
|
## Contribute
|
|
234
234
|
|
|
235
|
-
TypeBox is open to community contribution. Please ensure you submit an issue before submitting
|
|
235
|
+
TypeBox is open to community contribution. Please ensure you submit an issue before submitting a pull request. The TypeBox project prefers open community discussion before accepting new features.
|