UNPKG

bs-ajv

Version:

BucklesScript bindings to Ajv (Another JSON Validator)

21 lines (20 loc) 476 B
/* just an exercise to see what the interface to Ajv is like */ const Ajv = require('ajv'); const ajv = new Ajv; const validate_me = { "xmessage": "hello world!" }; const schema = { "title": "Message", "type": "object", "properties": { "message": { "type": "string" } }, "required": [ "message" ] }; const validate = ajv.compile(schema); const valid = validate(validate_me); console.log('valid=', valid); console.log('errors=', validate.errors);