You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently using @fastify/type-provider-typebox for schema validation in a Fastify application, and I'm interested in understanding how to handle the validation errors more effectively.
While this format is more structured, I'm still unsure if it's the right approach, and I have a few questions:
Questions:
Is structuring the error message (using setErrorHandler(customErrorFormat)) in the provided format the recommended approach for handling schema validation errors?
Can I customize the error messages for each instance path in the schema validation error?
How do developers typically handle these issues in real-life scenarios when using schema validation?
I would appreciate any insights or advice.
The text was updated successfully, but these errors were encountered:
in most modern web apps, form validation does not happen on the server. It's implemented in the client before the data is sent. It allows for a better DX.
Description:
I am currently using @fastify/type-provider-typebox for schema validation in a Fastify application, and I'm interested in understanding how to handle the validation errors more effectively.
Below is a simplified version of my setup:
app.ts:
user.schema.ts:
userRoute.ts:
When there's a validation error, the error message I receive is in string format:
I'm concerned about handling these error messages on the frontend as the message is in string format.
To improve this, I tried customizing the error format using the
setErrorHandler
method:app.ts (with custom error format):
With this setup, I get the errors in the following format:
While this format is more structured, I'm still unsure if it's the right approach, and I have a few questions:
Questions:
setErrorHandler(customErrorFormat)
) in the provided format the recommended approach for handling schema validation errors?I would appreciate any insights or advice.
The text was updated successfully, but these errors were encountered: