turkerdev / fastify-type-provider-zod

MIT License
411 stars 25 forks source link

Should this library work with fastify's setSchemaErrorFormatter method? #96

Open wolverian opened 4 months ago

wolverian commented 4 months ago

Looking at Fastify's documentation, I found this: https://fastify.dev/docs/latest/Reference/Validation-and-Serialization/#schemaerrorformatter

However, I can't get Fastify to call my custom schema error formatter:

  .setSchemaErrorFormatter(
    (errors: FastifySchemaValidationError[], dataVar: SchemaErrorDataVar) =>
      generateError(errors.map((err) => err.message)), // generateErrors is from zod-error
  )

Is this supposed to work or am I misunderstanding what a schema error formatter is?