ZodSchemaClassBuilder work
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Julien Valverdé
2024-02-22 06:06:40 +01:00
parent 46461cd373
commit 55d8bb0c1b
2 changed files with 28 additions and 22 deletions

View File

@@ -1,38 +1,26 @@
import { Implements, TraitExpression } from "@thilawyn/traitify-ts"
import { z } from "zod"
import { ZodSchemaClass, ZodSchemaClassBuilder } from "./ZodSchemaClass"
import { ZodSchemaClassBuilder } from "./ZodSchemaClass"
import { ObservableZodSchemaObject } from "./traits/ObservableZodSchemaObject"
const newTestExp = new ZodSchemaClassBuilder(TraitExpression.NullSuperclass, [])
.schema(
z.object({
.schema({
schema: z.object({
/** Object ID */
id: z.bigint(),
name: z.string(),
}),
{ id: -1n },
)
.expresses(ObservableZodSchemaObject)
.build()
const TestExp = ZodSchemaClass({
schema: z.object({
/** Object ID */
id: z.bigint(),
name: z.string(),
}),
defaultValues: { id: -1n },
})
defaultValues: { id: -1n },
})
.expresses(ObservableZodSchemaObject)
.build()
@newTestExp.staticImplements
class Test extends newTestExp.extends implements Implements<typeof newTestExp> {}
Test.schema
Test.defaultValues
const inst = Test.create({ id: 1n, name: "" })
console.log(inst)