Validate Workflow `startTrigger` Data

I am not sure how everyone else is validating and parsing workflow inputs, but I recently found valibot and it works so well in Retool. It has zero dependencies and is really easy to compose validation pipelines.

I would vote to add it as a default package with moment, lodash, papaparse, etc...

This is now how the start of my workflows look:

I even exported this little bit as a starter to use as a template.

5 Likes

This should be pinned or something, not validating input is not only VERY dangerous but it also opens up a ton of possible edge-cases that if you don't account for all of them can easily lead to hard to track down bugs.

Ideally, all input should be cleaned and validated on input (when entered) which would be on the front-end, but since workflows can be called by webhooks it's best to put validation in the workflow instead of assuming whoever is using your webhook will use it correctly... you might end up cleaning and validating twice (once on your own front-end and once in the webhook), but the minimal overhead is a sacrifice worth taking if you aren't the only one using the webhook. sometimes it's worth it even if you are the only one.... personally, i don't trust myself to remember everything so I'm safer risking double validation vs risking hunting down some sneaky bug

2 Likes