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

This commit is contained in:
Julien Valverdé
2024-02-21 04:45:43 +01:00
parent 4020f99d18
commit 1b9fa09186
2 changed files with 34 additions and 13 deletions

View File

@@ -1,6 +1,7 @@
import { Implements } from "@thilawyn/traitify-ts"
import { z } from "zod"
import { ZodSchemaClass } from "./ZodSchemaClass"
import { ObservableZodSchemaObject } from "./traits/ObservableZodSchemaObject"
const TestExp = ZodSchemaClass({
@@ -11,12 +12,14 @@ const TestExp = ZodSchemaClass({
}),
defaultValues: { id: -1n },
}).build()
})
.expresses(ObservableZodSchemaObject)
.buildAnyway()
@TestExp.implementsStatic
class Test extends TestExp.extends implements Implements<typeof TestExp> {}
Test.defaultValues
Test.schema
const inst = Test.create({ id: 1n, name: "" })
console.log(inst)
@@ -37,3 +40,15 @@ console.log(subInst)
// class ChildTest extends Test {}
// ChildTest.instantiate({ name: "" })
const testSchema = { schema: Test.schema }
declare const testGenericSchema: {
schema: z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny, object, object>
}
type U<T> = T
interface ExtendTest extends U<typeof testSchema> {
schema: z.ZodObject<any, any, any, any, any>
}