This commit is contained in:
@@ -16,9 +16,9 @@ export function ZodSchemaClass<
|
|||||||
Values extends object,
|
Values extends object,
|
||||||
PartialValues extends Partial<Values>,
|
PartialValues extends Partial<Values>,
|
||||||
>(
|
>(
|
||||||
schema: z.ZodObject<T, "strip", Catchall, Values, PartialValues>
|
schemaWithDefaults: z.ZodObject<T, "strip", Catchall, Values, PartialValues>
|
||||||
) {
|
) {
|
||||||
return expression
|
return expression
|
||||||
.extends(ZodSchemaObjectConstructor<Values>)
|
.extends(ZodSchemaObjectConstructor<Values>)
|
||||||
.expresses(ZodSchemaObject(schema))
|
.expresses(ZodSchemaObject(schemaWithDefaults))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,19 @@
|
|||||||
// import { trait } from "@thilawyn/traitify-ts"
|
import { expression } from "@thilawyn/traitify-ts"
|
||||||
// import { ZodSchemaClassExtender } from "../builders/ZodSchemaClassExtender"
|
import { z } from "zod"
|
||||||
// import { ZodSchemaClass } from "../shapes/ZodSchemaClass"
|
import { ZodSchemaObject } from "./ZodSchemaObject"
|
||||||
|
|
||||||
|
|
||||||
// export const ExtendableZodSchemaObject = trait
|
export const ExtendableZodSchemaObject = <
|
||||||
// .implement(Super => class ExtendableZodSchemaObject extends Super {
|
T extends z.ZodRawShape,
|
||||||
// static extend<
|
Catchall extends z.ZodTypeAny,
|
||||||
// Self extends ZodSchemaClass<any, any, any, any, any, any, any, any, any>,
|
Values extends object,
|
||||||
// >(
|
PartialValues extends Partial<Values>,
|
||||||
// this: Self
|
>(
|
||||||
// ) {
|
schemaWithDefaults: z.ZodObject<T, "strip", Catchall, Values, PartialValues>,
|
||||||
// return new ZodSchemaClassExtender(this, this)
|
) => expression
|
||||||
// }
|
.expresses(ZodSchemaObject(schemaWithDefaults))
|
||||||
// })
|
.buildAnyway()
|
||||||
// .build()
|
.subtrait()
|
||||||
|
.implement(Super => class ExtendableZodSchemaObject extends Super {
|
||||||
|
})
|
||||||
|
.build()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { ImplStatic, trait } from "@thilawyn/traitify-ts"
|
import { ImplStatic, trait } from "@thilawyn/traitify-ts"
|
||||||
import { AbstractClass, Class, HasRequiredKeys } from "type-fest"
|
import { Class, HasRequiredKeys } from "type-fest"
|
||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
import { StaticMembers, parseZodSchemaEffect, stripZodObjectDefaults } from "../util"
|
import { StaticMembers, parseZodSchemaEffect, stripZodObjectDefaults } from "../util"
|
||||||
|
|
||||||
@@ -85,13 +85,24 @@ export const ZodSchemaObject = <
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static extend<
|
// static extend<
|
||||||
Self extends AbstractClass<ZodSchemaObject> & ImplStatic<typeof ZodSchemaObject>
|
// Self extends AbstractClass<ZodSchemaObject> & ImplStatic<typeof ZodSchemaObject>,
|
||||||
>(
|
|
||||||
this: Self
|
|
||||||
) {
|
|
||||||
|
|
||||||
}
|
// ExtendedT extends z.ZodRawShape,
|
||||||
|
// ExtendedCatchall extends z.ZodTypeAny,
|
||||||
|
// ExtendedValues extends Values,
|
||||||
|
// ExtendedPartialValues extends Partial<ExtendedValues>,
|
||||||
|
// >(
|
||||||
|
// this: Self,
|
||||||
|
|
||||||
|
// schemaWithDefaults: (
|
||||||
|
// schemaWithDefaults: typeof this.schemaWithDefaults
|
||||||
|
// ) => z.ZodObject<ExtendedT, "strip", ExtendedCatchall, ExtendedValues, ExtendedPartialValues>,
|
||||||
|
// ) {
|
||||||
|
// return expression
|
||||||
|
// .extends(this)
|
||||||
|
// .expresses(ZodSchemaObject(schemaWithDefaults(this.schemaWithDefaults)))
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
return ZodSchemaObject as Class<ZodSchemaObject & Values> & StaticMembers<typeof ZodSchemaObject>
|
return ZodSchemaObject as Class<ZodSchemaObject & Values> & StaticMembers<typeof ZodSchemaObject>
|
||||||
|
|||||||
Reference in New Issue
Block a user