in src/schema/validator.js [526:568]
function createManifestVersionValidateFn(keyword, condFn) {
// function of type SchemaValidateFunction (see ajv typescript signatures).
return function validate(
keywordSchemaValue,
propValue,
schema,
{ rootData /* instancePath, parentData, parentDataProperty, */ }
) {
const manifestVersion =
(rootData && rootData.manifest_version) || MANIFEST_VERSION_DEFAULT;
const res = condFn(keywordSchemaValue, manifestVersion);
// If the min/max_manifest_version is set on a schema entry of type array,
// propagate the same keyword to the `items` schema, which is needed to
// - be able to recognize that those schema entries are also only allowed on
// certain manifest versions (which becomes part of the linting messages)
// - be able to filter out the validation errors related to future (not yet
// supported) manifest versions if they are related to those schema entries
// (which happens based on the current or parent schema in the `filterErrors`
// helper method).
if (schema.type === 'array') {
// TODO(#3774): move this at "import JSONSchema data" time, and remove it from here.
// eslint-disable-next-line no-param-reassign
schema.items[keyword] = schema[keyword];
}
if (!res) {
// If the addon manifest is out of an enum values min/max manifest version range,
// don't report an additional validation error for the min/max_manifest_version
// keyword validation function.
if (schema.enum) {
return true;
}
validate.errors = [
{
keyword,
params: { [keyword]: keywordSchemaValue },
},
];
}
return res;
};
}