Prim+RPC does not include validation of arguments and return values by default but this can easily be added in one of several ways, using the validation tool of your choice.
See the Security guide to learn various ways of setting up validation. In this guide, we’ll see how to set up several popular validation libraries with our functions directly. However we could just as easily move this validation into a Pre-Call or Post-Call hook.
For all of these examples we will be adding validation to this example function (implementation can generally be ignored, we will only be focusing on the validation of inputs):
Zod is a very popular form of validation. We could set up validation like so:
ArkType is a recent library gaining traction for its resemblance to TypeScript types. We could set up validation like so:
Valibot is an alternative to Zod that has a tree-shakeable design.
The examples on this page are not exhaustive. You may use any validation library that you’d like.
Report an Issue