My First Playground

node v8.17.0
version: 2.0.0
endpointsharetweet
This is a playground to test JavaScript. It runs a completely standard copy of Node.js on a virtual server created just for you. Every one of npm’s 300,000+ packages are pre-installed, so try it out:
Ajv = require("ajv") log = console.log; var getJSON = require("async-get-json"); var schema = await getJSON("https://customers-2db8.restdb.io/static/db/schema.json"); log(schema);
// Intentionally corrupt the schema by // changing /definitions/address/$id from "#address" to "#address_broken" schema.definitions.address['$id'] = '#address_broken'; // The schema contains some { $ref: '#address' }-references.
log(schema.definitions.address['$id']); // just to make sure
ajv = new Ajv({ allErrors : true, verbose : true, jsonPointers : true, format : 'full', sourceCode : true, });
try { let validate = ajv.compile(schema); } catch (exeption) { log("error was ::", exeption); log("any errors on Ajv's errors object ?", ajv.errors); } /* I found that all other errors show up in the ajv.error-array and they do carry either a JSONPointer or a dataPath (depends on config). The dataPath/JSONPoint is a big help in finding the spot. I'm working json-schema-support for Atom's linting-framework, thus i'm gratefull for good locality-info. */
Loading…

no comments

    sign in to comment