CoolFace
Apppublic

Umama-at-Bluchip/Quick-UI

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
.tonic_example.js20 linesDownload Raw Back to ajv
1var Ajv = require('ajv');2var ajv = new Ajv({allErrors: true});3 4var schema = {5  "properties": {6    "foo": { "type": "string" },7    "bar": { "type": "number", "maximum": 3 }8  }9};10 11var validate = ajv.compile(schema);12 13test({"foo": "abc", "bar": 2});14test({"foo": 2, "bar": 4});15 16function test(data) {17  var valid = validate(data);18  if (valid) console.log('Valid!');19  else console.log('Invalid: ' + ajv.errorsText(validate.errors));20}