Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including simple-ajv-errors with all npm packages installed. Try it out:

const Ajv = require("ajv"); const { getSimpleErrorText } = require("simple-ajv-errors"); const ajv = new Ajv({allErrors: true, verbose: true}); const schema = { "type": "object", "properties": { "maxDepth": { "oneOf": [ { "type": "integer", "minimum": 1 }, { "type": "string", "enum": ["∞"] } ] } }, "additionalProperties": false }; const validate = ajv.compile(schema); function test(data) { validate(data); console.log("AJV:"); console.log(ajv.errorsText(validate.errors, { separator: "\n", dataVar: "data" })); console.log("\n"); console.log("simple-ajv-errors:"); console.log(getSimpleErrorText(validate.errors, { separator: "\n", dataVar: "data" })); console.log("\n"); console.log("---------------------------"); console.log("\n"); } test({maxDepth: "2"}); test({maxDepth: "2", minAllowed: 3});

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

simple-ajv-errors v1.0.1

Parses AJV errors and determines the best message

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free