Ajv issue - IPv4 address satisfies 'hostname' format (github.com/ajv-validator/ajv/issues/832)
$ npm install
$ node index.jsAjv issue - IPv4 address satisfies 'hostname' format (github.com/ajv-validator/ajv/issues/832)
$ npm install
$ node index.js| var Ajv = require("ajv"); | |
| ajv = new Ajv({ | |
| }); | |
| var schema = { | |
| "type": "object", | |
| "properties": { | |
| "host": { | |
| "type": "string", | |
| "oneOf": [ | |
| { "format": "hostname" }, | |
| { "format": "ipv4" } | |
| ] | |
| } | |
| } | |
| }; | |
| var data = { | |
| "host": "127.0.0.1" | |
| }; | |
| var validate = ajv.compile(schema); | |
| console.log(validate(data)); | |
| console.log(validate.errors); |
| { | |
| "dependencies": { | |
| "ajv": "6.5.2" | |
| } | |
| } |
| false | |
| [ { keyword: 'oneOf', | |
| dataPath: '.host', | |
| schemaPath: '#/properties/host/oneOf', | |
| params: { passingSchemas: [Array] }, | |
| message: 'should match exactly one schema in oneOf' } ] |