This commit is contained in:
@@ -36,23 +36,19 @@ export const ZodSchemaObject = <
|
||||
static readonly schemaWithDefaultsValues = schemaWithDefaultValues(schema)
|
||||
|
||||
static instantiationSchema<
|
||||
Instance extends Values
|
||||
Self extends StaticMembers<ImplStaticThis<typeof ZodSchemaObject>>,
|
||||
Instance extends Values,
|
||||
>(
|
||||
this: (
|
||||
Class<Instance, [values: Values]> &
|
||||
StaticMembers<ImplStaticThis<typeof ZodSchemaObject>>
|
||||
)
|
||||
this: Class<Instance, [values: Values]> & Self
|
||||
) {
|
||||
return this.schema.transform(values => new this(values))
|
||||
}
|
||||
|
||||
static instantiationSchemaWithDefaultValues<
|
||||
Instance extends Values
|
||||
Self extends StaticMembers<ImplStaticThis<typeof ZodSchemaObject>>,
|
||||
Instance extends Values,
|
||||
>(
|
||||
this: (
|
||||
Class<Instance, [values: Values]> &
|
||||
StaticMembers<ImplStaticThis<typeof ZodSchemaObject>>
|
||||
)
|
||||
this: Class<Instance, [values: Values]> & Self
|
||||
) {
|
||||
return this.schema.transform(values => new this(values))
|
||||
}
|
||||
@@ -67,7 +63,7 @@ export const ZodSchemaObject = <
|
||||
),
|
||||
...[values, params]: NewZodSchemaInstanceArgs<PartialValues>
|
||||
) {
|
||||
return this.instantiationSchema().parse(values, params)
|
||||
return this.instantiationSchemaWithDefaultValues().parse(values, params)
|
||||
}
|
||||
})
|
||||
.build()
|
||||
|
||||
Reference in New Issue
Block a user