deno.land / x / typebox@0.32.21 / example / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { TypeSystem } from '@sinclair/typebox/system'import { TypeCompiler } from '@sinclair/typebox/compiler'import { Value, ValuePointer } from '@sinclair/typebox/value'import { Type, TypeGuard, Kind, Static, TSchema } from '@sinclair/typebox'
// -----------------------------------------------------------// Create: Type// -----------------------------------------------------------
const T = Type.Object({ x: Type.Number(), y: Type.Number(), z: Type.Number(),})
type T = Static<typeof T>
console.log(T)
// -----------------------------------------------------------// Create: Value// -----------------------------------------------------------
const V = Value.Create(T)
console.log(V)
// -----------------------------------------------------------// Compile: Type// -----------------------------------------------------------
const C = TypeCompiler.Compile(T)
console.log(C.Code())
// -----------------------------------------------------------// Check: Value// -----------------------------------------------------------
console.log(C.Check(V))
typebox

Version Info

Tagged at
4 weeks ago