mirror of
https://github.com/zoriya/typebox.git
synced 2026-06-01 18:45:32 +00:00
Update Example
This commit is contained in:
+26
-1
@@ -8,8 +8,11 @@ import { Custom } from '@sinclair/typebox/custom'
|
||||
import { Value, ValuePointer } from '@sinclair/typebox/value'
|
||||
import { Type, Kind, Static, TSchema } from '@sinclair/typebox'
|
||||
|
||||
// -----------------------------------------------------------
|
||||
// Create: Type
|
||||
// -----------------------------------------------------------
|
||||
|
||||
const T = Type.Object({
|
||||
/** It's a X */
|
||||
x: Type.Number(),
|
||||
y: Type.Number(),
|
||||
z: Type.Number(),
|
||||
@@ -18,3 +21,25 @@ const T = Type.Object({
|
||||
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))
|
||||
|
||||
Reference in New Issue
Block a user