ExtendableZodSchemaObject
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Julien Valverdé
2024-03-16 23:20:39 +01:00
parent 2bf207883f
commit 11f384d933
3 changed files with 37 additions and 23 deletions

View File

@@ -1,16 +1,19 @@
// import { trait } from "@thilawyn/traitify-ts"
// import { ZodSchemaClassExtender } from "../builders/ZodSchemaClassExtender"
// import { ZodSchemaClass } from "../shapes/ZodSchemaClass"
import { expression } from "@thilawyn/traitify-ts"
import { z } from "zod"
import { ZodSchemaObject } from "./ZodSchemaObject"
// export const ExtendableZodSchemaObject = trait
// .implement(Super => class ExtendableZodSchemaObject extends Super {
// static extend<
// Self extends ZodSchemaClass<any, any, any, any, any, any, any, any, any>,
// >(
// this: Self
// ) {
// return new ZodSchemaClassExtender(this, this)
// }
// })
// .build()
export const ExtendableZodSchemaObject = <
T extends z.ZodRawShape,
Catchall extends z.ZodTypeAny,
Values extends object,
PartialValues extends Partial<Values>,
>(
schemaWithDefaults: z.ZodObject<T, "strip", Catchall, Values, PartialValues>,
) => expression
.expresses(ZodSchemaObject(schemaWithDefaults))
.buildAnyway()
.subtrait()
.implement(Super => class ExtendableZodSchemaObject extends Super {
})
.build()