Skip to content

Commit

Permalink
fix: fix zod validation for getAllSql query (#294)
Browse files Browse the repository at this point in the history
  • Loading branch information
rameshlohala committed Mar 30, 2023
1 parent 43e1f46 commit 4d239d0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/slonik/src/sqlFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ class DefaultSqlFactory<
fieldsObject[field] = true;
}

// [RL 2023-03-30] this should be done checking if the validation schema is of instanceof ZodObject
const allSchema =
this.validationSchema instanceof z.ZodObject
? this.validationSchema.pick(fieldsObject)
this.validationSchema._def.typeName === "ZodObject"
? (this.validationSchema as z.AnyZodObject).pick(fieldsObject)
: z.any();

return sql.type(allSchema)`
Expand Down

0 comments on commit 4d239d0

Please sign in to comment.