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

Version Path
ilog-0.4.1 node_modules/ajv/.tonic_example.js
ilog-0.4.0 node_modules/ajv/.tonic_example.js
ilog-0.3.3 node_modules/ajv/.tonic_example.js
affiliator-0.2.1 node_modules/fsevents/node_modules/ajv/.tonic_example.js
guard-sass-lint-0.1.2 node_modules/ajv/.tonic_example.js
guard-sass-lint-0.1.1 node_modules/ajv/.tonic_example.js
lanes-0.8.0 node_modules/ajv/.tonic_example.js