removeAdditional does not work when additionalProperties is not explicitly false
Author: preederCreated Aug 10, 2026Updated Aug 10, 2026
Labelsbug report
What version of Ajv are you using? Does the issue happen if you use the latest version? 8.20.0
Ajv options object
{ removeAdditional: true }JSON Schema
{
type: 'object',
additionalProperties: {
not: true
},
properties: {
validProp: {
type: 'number'
}
}
}Sample data { validProp: 1, invalidProp: 2 }
Your code
const ajv = new Ajv(options);
const validator = ajv.compile(schema);
const result = validator(data);
console.info('result: ', result);
console.info('data: ', data);
if (!result){
console.info('Errors: ', validator.errors);
}Validation result, data AFTER validation, error messages
result: false
data: { validProp: 1, invalidProp: 2 }
Errors: [
{
instancePath: '/invalidProp',
schemaPath: '#/additionalProperties/not',
keyword: 'not',
params: {},
message: 'must NOT be valid'
}
]What results did you expect? I expected validation to pass and 'invalidProp' to be removed from data.
Are you going to resolve the issue? Yes
Source: ajv-validator/ajv