This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { ImplStaticThis, trait } from "@thilawyn/traitify-ts"
|
||||
import { ImplStatic, trait } from "@thilawyn/traitify-ts"
|
||||
import { Class, HasRequiredKeys } from "type-fest"
|
||||
import { z } from "zod"
|
||||
import { StaticMembers, parseZodSchemaEffect } from "../util"
|
||||
import { parseZodSchemaEffect } from "../util"
|
||||
|
||||
|
||||
type ParseParamsArgs = [] | [params: Partial<z.ParseParams>]
|
||||
@@ -32,7 +32,7 @@ export const ZodSchemaObject = <
|
||||
static readonly schema = schema
|
||||
static readonly schemaWithDefaultsValues = schemaWithDefaultValues
|
||||
|
||||
static instantiationTransform<
|
||||
static transform<
|
||||
Instance extends Values,
|
||||
|
||||
T extends z.ZodRawShape,
|
||||
@@ -53,12 +53,12 @@ export const ZodSchemaObject = <
|
||||
>(
|
||||
this: (
|
||||
Class<Instance, [values: Values]> &
|
||||
StaticMembers<ImplStaticThis<typeof ZodSchemaObject>>
|
||||
ImplStatic<typeof ZodSchemaObject>
|
||||
),
|
||||
...[values, params]: NewZodSchemaInstanceArgs<PartialValues>
|
||||
) {
|
||||
return this
|
||||
.instantiationTransform(this.schemaWithDefaultsValues)
|
||||
.transform(this.schemaWithDefaultsValues)
|
||||
.parse(values, params)
|
||||
}
|
||||
|
||||
@@ -67,12 +67,12 @@ export const ZodSchemaObject = <
|
||||
>(
|
||||
this: (
|
||||
Class<Instance, [values: Values]> &
|
||||
StaticMembers<ImplStaticThis<typeof ZodSchemaObject>>
|
||||
ImplStatic<typeof ZodSchemaObject>
|
||||
),
|
||||
...[values, params]: NewZodSchemaInstanceArgs<PartialValues>
|
||||
) {
|
||||
return this
|
||||
.instantiationTransform(this.schemaWithDefaultsValues)
|
||||
.transform(this.schemaWithDefaultsValues)
|
||||
.parseAsync(values, params)
|
||||
}
|
||||
|
||||
@@ -81,12 +81,12 @@ export const ZodSchemaObject = <
|
||||
>(
|
||||
this: (
|
||||
Class<Instance, [values: Values]> &
|
||||
StaticMembers<ImplStaticThis<typeof ZodSchemaObject>>
|
||||
ImplStatic<typeof ZodSchemaObject>
|
||||
),
|
||||
...[values, params]: NewZodSchemaInstanceArgs<PartialValues>
|
||||
) {
|
||||
return parseZodSchemaEffect(
|
||||
this.instantiationTransform(this.schemaWithDefaultsValues),
|
||||
this.transform(this.schemaWithDefaultsValues),
|
||||
values,
|
||||
params,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user