fix: (types) allow FastifySchemaValidationError[] as an error#6326
Merged
fix: (types) allow FastifySchemaValidationError[] as an error#6326
Conversation
jean-michelet
approved these changes
Sep 22, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds the
FastifySchemaValidationError[]type to theerrorproperty ofFastifyValidationResultthat the code at runtime handles but is invisible:fastify/lib/validation.js
Lines 241 to 255 in 9a67d3a
The code above calls
schemaErrorFormatterif the property is not an error object, which by default handles an array ofFastifySchemaValidationErrorobjects:fastify/lib/context.js
Lines 84 to 93 in 9a67d3a
Not having this type causes Type Providers in the ecosystem to assert the type incorrectly:
https://github.com/fastify/fastify-type-provider-typebox/blob/2c8319e69070482b83bb527c9ae8fe7fcbcc4d94/index.mts#L26
https://github.com/fastify/fastify-type-provider-typebox/pull/243/files#diff-382414b6b7a87c32132ad230c522280fe2a6d4efdaf7e32cc5ef3917dbb0404dR35
https://github.com/turkerdev/fastify-type-provider-zod/blob/4e658779dbc788356b9b9e3c67fea6d17aca801e/src/core.ts#L187-L189