Repository navigation
Conversation
Reuse ordered Ajv branch validation in the native projection. Preserve conversion output and keep the string codegen where schema merging or serialization options require it. Refs fastify#942
This branch has not been deployed
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.
Closes #942.
Summary
Allow
objectMechanism: 'native'to projectanyOfwith one supported scalar branch and one null branch. The projection calls the same Ajv branch validators in the same order as the ordinary serializer. Constraints, coercion, and mismatch errors remain observable.The patch keeps the ordinary path when branch merging can change the result. The runtime projection preserves the ordinary string conversion for custom
toString()results. The eligibility checks also keep the configured large-array bypass and the ordinary byte order when integer-named keys conflict with required-property order.Verification
npm testpassed on Node 20.20.2, 22.23.4, 24.22.3, and 26.13.1 on macOS ARM64. Each ran 730 unit tests at 100% reported coverage and 15 type assertions.npm run lintandnpm run benchmark --if-presentpassed.Buffer.byteLengthfell from 205.07 ms to 149.02 ms over 300,000 one-row responses and from 413.53 ms to 265.70 ms over 40,000 25-row responses. Nine alternating samples per workload on Node 26.13.1, macOS ARM64. Both serializers emitted identical bytes for all fixture payloads.Checklist
npm run test && npm run benchmark --if-present