Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
ajv-error-messages
Advanced tools
Normalise errors from ajv to a simpler format.
Takes ajv errors and returns a simpler object. Inspired by https://github.com/MauriceButler/jayschema-error-messages
v2 of ajv-error-messages
has been upgraded to work with v8 of ajv
var normalise = require('ajv-error-messages');
var SchemaValidator = require('ajv');
var schemaValidator = SchemaValidator({ allErrors: true });
var schema = {
description: 'test schema',
type: 'object',
additionalProperties: false,
required: ['foo'],
properties: {
foo: {
type: 'string',
},
},
};
var invalidData = {
foo: 2,
};
var validator = schemaValidator.compile(schema);
function validatingData(data) {
var valid = validator(data);
var normalisedErrors;
if (!valid) {
var ajvErrors = validator.errors
normalisedErrors = normalise(ajvErrors);
}
return valid || normalisedErrors;
}
console.log(JSON.stringify(validatingData(invalidData)));
results in
{
fields: {
'foo': ['Must be string']
}
}
FAQs
Normalise AJV error messages
We found that ajv-error-messages demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.