graasp / graasp/graasp-api

Integrate ajv-errors into the schema validation

Open
#1,423 0 comments 0 reactions 0 assignees View on GitHub
improvement
Dominant language
TypeScript
Stars
7
Forks
5
PR merge metrics
No merged PRs in 30d

Description

If the system throws out an error related to the object schema, for example due to non-respect of formatting, the user gets a cryptic error that says something like `format not respected for body/name`. Using [ajv-errors](https://ajv.js.org/packages/ajv-errors.html) allows us to define more precise errors in case schema validation fails.

By using ajv-errors we can send much clearer error message upon schema validation failures. It would also allow us to have a schema-first approach to errors instead of throwing custom errors in controllers.

Unfortunately the [documentation](https://fastify.dev/docs/latest/Reference/Validation-and-Serialization/#error-handling) on integration of ajv-errors in Fastify seems completely outdated and the described path does not work. We can see if the upgrade to Fastify v5 resolves the issue, or, worst case, we can roll our own ajv and integrate it into Fastify.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.