Sha256: 2eecf7d8d4dfd9fae295904305d0efa845234e0140db71e09bf7bb359dcb377f
Contents?: true
Size: 435 Bytes
Versions: 7
Compression:
Stored size: 435 Bytes
Contents
var Ajv = require('ajv'); var ajv = Ajv({allErrors: true}); var schema = { "properties": { "foo": { "type": "string" }, "bar": { "type": "number", "maximum": 3 } } }; var validate = ajv.compile(schema); test({"foo": "abc", "bar": 2}); test({"foo": 2, "bar": 4}); function test(data) { var valid = validate(data); if (valid) console.log('Valid!'); else console.log('Invalid: ' + ajv.errorsText(validate.errors)); }
Version data entries
7 entries across 7 versions & 4 rubygems