RunKit + npm: ajv

node v10.24.1
endpointsharetweet
var Ajv = require('ajv'); var schema = { definitions: { Data: { "properties": { "foo": { "type": "string" }, "bar": { "type": "number", "maximum": 3 }, "arr": {"type":"array","items":{$ref:"#/definitions/Item"}} } }, Item: { "properties": { "xx": {type: "string"} } } } }; var ajv = new Ajv({ schemas: [schema] }); console.log(ajv.validate('#/definitions/Data', { foo: "xx", bar: 2 }))
Created from: https://npm.runkit.com/ajv
Loading…