Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ajv-error-tree

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ajv-error-tree - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

2

package.json
{
"name": "ajv-error-tree",
"version": "0.0.2",
"version": "0.0.3",
"scripts": {

@@ -5,0 +5,0 @@ "test": "node test/test.js",

# ajv-error-tree
Convert a list of [ajv](https://www.npmjs.com/package/ajv) errors into the logical tree it was always meant to be.
See [sample](test/sample.js) for an example.
Requirement: `ajv@8.x.x`.
Example:
```js
const Ajv = require("ajv");
const YAML = require("yaml");
const { asTree } = require("treeify");
const {
structureAJVErrorArray,
summarizeAJVErrorTree,
} = require("ajv-error-tree");
const ajv = new Ajv({ verbose: true });
const validate = ajv.compile({
type: "array",
items: {
anyOf: [
{type: "number"},
{type: "boolean"}
]
}
});
console.assert(!validate([123, true, "foo"]));
const tree1 = structureAJVErrorArray(validate.errors);
const tree2 = summarizeAJVErrorTree(tree1);
console.log(asTree(tree2, true));
// ├─ .: /items/anyOf >> /2 must match a schema in anyOf
// └─ +
// ├─ 0: /items/anyOf/0/type >> /2 must be number
// └─ 1: /items/anyOf/1/type >> /2 must be boolean
```
See [sample](test/sample.js) for another example.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc