turkerdev / fastify-type-provider-zod

MIT License
386 stars 24 forks source link

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

Open wolverian opened 3 months ago

wolverian commented 3 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?