Clone and edit this document
Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
AJV uniqueItems Objects
node v10.24.1
version:
master
endpoint
share
tweet
var Ajv = require('ajv'); var ajv = new Ajv({allErrors: true}); var schema = { "type": "array", "uniqueItems": true, "items": { "type": "object", "properties": { "a": { "type": "string", }, "b": { "type": "string" } } } } var validate = ajv.compile(schema); test([ { "a": "1", "b": "2" }, { "b": "2", "a": "1" } ]); function test(data) { var valid = validate(data); if (valid) console.log('Valid!'); else console.log('Invalid: ' + ajv.errorsText(validate.errors)); }
Created from: https://npm.runkit.com/ajv
Loading…
no comments
sign in
to comment