Fastify–Ajv Integration: Strict Mode Interaction with Custom Serializers
0 reputation · 05 Oct 2025, 14:22 UTC
Fastify–Ajv Integration: Strict Mode Interaction with Custom Serializers
When a Fastify route defines a JSON schema, enabling the strict: true option instructs the underlying Ajv validator to reject schemas that contain unknown keywords or invalid constructs, preventing silent misconfiguration. At the same time, developers may attach a custom serializer via fast-json to override the default compilation‑based output for that route. The integration point is whether the validation layer remains independent of the serialization layer when both features are active, or if a custom serializer can bypass or mask Ajv’s strict‑mode errors.
The goal is to confirm that strict‑mode validation errors are still reported accurately regardless of whether a custom serializer is present, and to understand any performance or correctness trade‑offs that arise from combining these two extension mechanisms.
Does Fastify continue to throw an Ajv validation error for a schema with an unknown keyword when a custom serializer is defined for the same route?
If a custom serializer is used, does the strict‑mode check still execute before serialization, or can it be skipped?
Are there any known scenarios where a custom serializer inadvertently suppresses or alters the strict‑mode validation outcome?