diff --git a/spec/options.spec.js b/spec/options.spec.js index 617d9e4..8b87f15 100644 --- a/spec/options.spec.js +++ b/spec/options.spec.js @@ -881,7 +881,7 @@ describe('Ajv Options', function () { } }); - it.skip('should throw during validation if unknown format is used via $data', function() { + it.skip('should fail validation if unknown format is used via $data', function() { test(new Ajv({v5: true, unknownFormats: true})); function test(ajv) { @@ -897,9 +897,7 @@ describe('Ajv Options', function () { validate({foo: '20161016', bar: 'date'}) .should.equal(false); validate({foo: '20161016'}) .should.equal(true); - should.throw(function() { - validate({foo: '2016-10-16', bar: 'unknown'}); - }); + validate({foo: '2016-10-16', bar: 'unknown'}) .should.equal(false); } }); }); @@ -967,10 +965,7 @@ describe('Ajv Options', function () { validate({foo: '20161016'}) .should.equal(true); validate({foo: '2016-10-16', bar: 'allowed'}) .should.equal(true); - - should.throw(function() { - validate({foo: '2016-10-16', bar: 'unknown'}); - }); + validate({foo: '2016-10-16', bar: 'unknown'}) .should.equal(false); } }); }); diff --git a/spec/schema-tests.spec.js b/spec/schema-tests.spec.js index 8a7b17f..117bd99 100644 --- a/spec/schema-tests.spec.js +++ b/spec/schema-tests.spec.js @@ -6,7 +6,7 @@ var jsonSchemaTest = require('json-schema-test') , suite = require('./brower_test_suite') , after = require('./after_test'); -var instances = getAjvInstances(options); +var instances = getAjvInstances(options, {unknownFormats: ['allowedUnknown']}); var remoteRefs = { 'http://localhost:1234/integer.json': require('./JSON-Schema-Test-Suite/remotes/integer.json'), diff --git a/spec/tests/rules/format.json b/spec/tests/rules/format.json index cb0bab8..ec15076 100644 --- a/spec/tests/rules/format.json +++ b/spec/tests/rules/format.json @@ -1,12 +1,12 @@ [ { - "description": "unknown format is always valid", + "description": "whitelisted unknown format is valid", "schema": { - "format": "unknownformat" + "format": "allowedUnknown" }, "tests": [ { - "description": "anything is valid", + "description": "any string is valid", "data": "any value", "valid": true } diff --git a/spec/tests/schemas/advanced.json b/spec/tests/schemas/advanced.json index f5d4ba2..12e94fc 100644 --- a/spec/tests/schemas/advanced.json +++ b/spec/tests/schemas/advanced.json @@ -72,7 +72,7 @@ "server": { "type": "string", "anyOf": [ - { "format": "host-name" }, + { "format": "hostname" }, { "format": "ipv4" }, { "format": "ipv6" } ] diff --git a/spec/v5.spec.js b/spec/v5.spec.js index 9d21a8e..2044095 100644 --- a/spec/v5.spec.js +++ b/spec/v5.spec.js @@ -6,7 +6,7 @@ var jsonSchemaTest = require('json-schema-test') , suite = require('./brower_test_suite') , after = require('./after_test'); -var instances = getAjvInstances(options, { v5: true }); +var instances = getAjvInstances(options, { v5: true, unknownFormats: ['allowedUnknown'] }); jsonSchemaTest(instances, { diff --git a/spec/v5/formatMaximum.json b/spec/v5/formatMaximum.json index 3c3864e..9e0e6c9 100644 --- a/spec/v5/formatMaximum.json +++ b/spec/v5/formatMaximum.json @@ -204,14 +204,14 @@ ] }, { - "description": "formatMaximum is valid with unknown format", + "description": "formatMaximum is valid with whitelisted unknown format", "schema": { - "format": "unknown", + "format": "allowedUnknown", "formatMaximum": "2015" }, "tests": [ { - "description": "always valid", + "description": "valid string", "data": "2016", "valid": true }