Skip to content

Commit

Permalink
Merge pull request #159 from asteasolutions/bugifx/#158-mimified-code…
Browse files Browse the repository at this point in the history
…-breaks-type-checks

use _def.typeName for type checking zod schemas
  • Loading branch information
AGalabov committed Jul 17, 2023
2 parents 347dab3 + f93be67 commit 2e6ca6e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/zod-is-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function isZodType<TypeName extends keyof ZodTypes>(
schema: object,
typeName: TypeName
): schema is ZodTypes[TypeName] {
return schema.constructor.name === typeName;
return (schema as any)?._def?.typeName === typeName;
}

export function isAnyZodType(schema: object): schema is z.ZodType {
Expand Down

0 comments on commit 2e6ca6e

Please sign in to comment.