SO 46726881

node v6.17.1
version: master
endpointsharetweet
const schema = { "type": "object", "properties": { "tag": {"type": "string"} }, "additionalProperties": {"type": "number"}, // schema for the second property value "propertyNames": { "anyOf": [ {"const": "tag"}, {"const": {"$data": "1/tag"} } ] } }; const Ajv = require('ajv'); const ajv = new Ajv({$data: true}); const validate = ajv.compile(schema); console.log(validate({tag: 'foo', foo: 1})); // true console.log(validate({tag: 'foo', foo: 'bar'})); // false console.log(validate({tag: 'foo', bar: 1})); // false
Loading…

no comments

    sign in to comment