test: whitelisted unknown formats should be valid (remove warnings), #310
parent
9bd850d115
commit
01ff755d4b
|
@ -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);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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'),
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
"server": {
|
||||
"type": "string",
|
||||
"anyOf": [
|
||||
{ "format": "host-name" },
|
||||
{ "format": "hostname" },
|
||||
{ "format": "ipv4" },
|
||||
{ "format": "ipv6" }
|
||||
]
|
||||
|
|
|
@ -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, {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue