ZodSchemaClassBuilder work
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
24
src/tests.ts
24
src/tests.ts
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user