Validation with AdditionalProperties: true by default?
- Dominant language
- No language data
- Stars
- 68
- Forks
- 8
- Avg merge
- 11h 2m
- Merged PRs (30d)
- 2
Description
Hi, I like having control on firing errors inside my routes, and i would like to do that also for the validation errors.
I see there is the option `additionalProperties: true` than can be used that won't throw an error but inject a `validationError` on the request parameter.
Is there a way to make this the default for all routes, or do I have to specify it for each route?
I've tried adding the property to my Ajv validator, but it doesn't work
```
const ajv = new Ajv({
coerceTypes: true, // change data type of data to match type keyword
useDefaults: true, // replace missing properties and items with the values from corresponding default keyword
removeAdditional: false, // remove additional properties
allErrors: false,
attachValidation: true
});
fastify.setValidatorCompiler(({ schema, method, url, httpPart }) => {
return ajv.compile(schema);
});
```
Thanks
Contributor guide
Assessment
This issue has not been assessed yet.