Managing the validator compiler
Fastify offers you the possibility to customize the validator compiler in two different manners:
- Configuring the default Ajv validator compiler
- Implementing a brand-new validator compiler, such as a new JSON Schema compiler module
These options give you total control over the validation process and the ability to react to every situation you may face, such as adopting a new validator compiler module or managing how the Ajv package processes the input data.
Configuring the default Ajv validator compiler
In the Understanding the Ajv configuration section, we saw the default Ajv settings and a link to its documentation to explore them all. If you find some useful options you would like to apply, you can set them during the Fastify instance instantiation:
const app = fastify({ ajv: { customOptions: { coerceTypes: 'array', ...