This commit is contained in:
@@ -3,6 +3,13 @@ import { z } from "zod"
|
||||
import { ZodSchemaObject } from "./lib"
|
||||
|
||||
|
||||
class ZodSchemaObjectConstructor<Values> {
|
||||
constructor(values: Values) {
|
||||
Object.assign(this, values)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export function ZodSchemaClass<
|
||||
SchemaT extends z.ZodRawShape,
|
||||
SchemaCatchall extends z.ZodTypeAny,
|
||||
@@ -20,16 +27,7 @@ export function ZodSchemaClass<
|
||||
) => z.ZodObject<SchemaWithDefaultValuesT, "strip", SchemaWithDefaultValuesCatchall, Values, PartialValues>
|
||||
}
|
||||
) {
|
||||
const schema = props.schema
|
||||
const schemaWithDefaultValues = props.schemaWithDefaultValues(props.schema)
|
||||
|
||||
abstract class ZodSchemaObjectConstructor {
|
||||
constructor(values: Values) {
|
||||
Object.assign(this, values)
|
||||
}
|
||||
}
|
||||
|
||||
return expression
|
||||
.extends(ZodSchemaObjectConstructor)
|
||||
.expresses(ZodSchemaObject(schema, schemaWithDefaultValues))
|
||||
.extends(ZodSchemaObjectConstructor<Values>)
|
||||
.expresses(ZodSchemaObject(props.schema, props.schemaWithDefaultValues(props.schema)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user