diff --git a/src/traits/ZodSchemaObject.ts b/src/traits/ZodSchemaObject.ts index 05fb8c5..fb479bb 100644 --- a/src/traits/ZodSchemaObject.ts +++ b/src/traits/ZodSchemaObject.ts @@ -41,7 +41,7 @@ export const ZodSchemaObject = < } static pipeInstanceIntoSchema< - Instance extends Values, + Self extends Class, SchemaT extends z.ZodRawShape, SchemaUnknownKeys extends z.UnknownKeysParam, @@ -49,14 +49,10 @@ export const ZodSchemaObject = < SchemaOutput, SchemaInput extends Values, >( - this: ( - Class & - ImplStatic - ), - - schema: z.ZodObject, + this: Self, + schema: z.ZodObject, ) { - return schema.transform(values => new this(values)) + return z.instanceof(this).pipe(schema) }