inngest-js icon indicating copy to clipboard operation
inngest-js copied to clipboard

[Feature] Validate event data against zod schema

Open elbalexandre opened this issue 2 years ago • 2 comments

Is your feature request related to a problem? Please describe. Event data is not validated against Zod schemas used for defining Inngest client event schemas.

Describe the solution you'd like When Zod schemas are used, the send() function should validate the provided data against the corresponding Zod schema.

Describe alternatives you've considered An alternative could be to remove EventSchemas.fromZod. This might be less ambiguous, as users familiar with Zod know they can use z.infer.

Additional context N/A

elbalexandre avatar Nov 24 '23 13:11 elbalexandre

Agreed, my assumption was that if I was providing a zod schema, the data was being validated, particularly because the event property handed to my function is typed according to the schema. This means that in a pretty normal webhook case, the type can be pretty easily wrong.

mattddean avatar Jul 16 '24 18:07 mattddean

There's a preliminary PR for this over at #657. Leaving this issue open to continue to gather feedback, but you can use that PR to get going now if you need this before we add a first-party option. 🙂

jpwilliams avatar Jul 19 '24 15:07 jpwilliams