Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

AJV uniqueItems Arrays

node v10.24.1
version: master
endpointsharetweet
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