This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { expression } from "@thilawyn/traitify-ts"
|
import { expression } from "@thilawyn/traitify-ts"
|
||||||
import { Class } from "type-fest"
|
import { Class } from "type-fest"
|
||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
import { ZodSchemaObject } from "./lib"
|
import { ExtendableZodSchemaObject } from "./traits/ExtendableZodSchemaObject"
|
||||||
|
|
||||||
|
|
||||||
export function ZodSchemaClass<
|
export function ZodSchemaClass<
|
||||||
@@ -20,5 +20,5 @@ export function ZodSchemaClass<
|
|||||||
}
|
}
|
||||||
} as Class<Values, [values: Values]>
|
} as Class<Values, [values: Values]>
|
||||||
)
|
)
|
||||||
.expresses(ZodSchemaObject(schemaWithDefaults))
|
.expresses(ExtendableZodSchemaObject(schemaWithDefaults))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { expression } from "@thilawyn/traitify-ts"
|
import { ImplStatic, expression } from "@thilawyn/traitify-ts"
|
||||||
|
import { AbstractClass } from "type-fest"
|
||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
import { ZodSchemaObject } from "./ZodSchemaObject"
|
import { ZodSchemaObject } from "./ZodSchemaObject"
|
||||||
|
|
||||||
@@ -15,5 +16,23 @@ export const ExtendableZodSchemaObject = <
|
|||||||
.build()
|
.build()
|
||||||
.subtrait()
|
.subtrait()
|
||||||
.implement(Super => class ExtendableZodSchemaObjectImpl extends Super {
|
.implement(Super => class ExtendableZodSchemaObjectImpl extends Super {
|
||||||
|
static extend<
|
||||||
|
Self extends AbstractClass<ExtendableZodSchemaObjectImpl> & ImplStatic<typeof ExtendableZodSchemaObjectImpl>,
|
||||||
|
|
||||||
|
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(ExtendableZodSchemaObject(schemaWithDefaults(this.schemaWithDefaults)))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.build()
|
.build()
|
||||||
|
|||||||
@@ -82,26 +82,6 @@ export const ZodSchemaObject = <
|
|||||||
params,
|
params,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// static extend<
|
|
||||||
// Self extends AbstractClass<ZodSchemaObject> & ImplStatic<typeof ZodSchemaObject>,
|
|
||||||
|
|
||||||
// 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)))
|
|
||||||
// }
|
|
||||||
})
|
})
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user