1 const Ajv = require("ajv")
2 const ajv = new Ajv({allErrors: true})
8 bar: {type: "number", maximum: 3},
10 required: ["foo", "bar"],
11 additionalProperties: false,
14 const validate = ajv.compile(schema)
16 test({foo: "abc", bar: 2})
17 test({foo: 2, bar: 4})
20 const valid = validate(data)
21 if (valid) console.log("Valid!")
22 else console.log("Invalid: " + ajv.errorsText(validate.errors))