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 Arrays
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": "array", "items": { "type": "string" } } }; var validate = ajv.compile(schema); test([ [ "a", "b" ], [ "b", "a" ] ]); 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