Skip to content

Commit

Permalink
support ajv v6.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
epoberezkin committed Jan 7, 2018
1 parent 7f1cc14 commit a52e7f8
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 17 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ localize/**/*.js
dist/

# IDE files
.idea
.idea

package-lock.json
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "spec/JSON-Schema-Test-Suite"]
path = spec/JSON-Schema-Test-Suite
url = https://github.com/json-schema/JSON-Schema-Test-Suite.git
[submodule "spec/ajv"]
path = spec/ajv
url = https://github.com/epoberezkin/ajv.git
4 changes: 4 additions & 0 deletions messages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,10 @@ module.exports = {
sk: 'formatExclusiveMinimum musí byť boolean',
sv: 'formatExclusiveMaximum bör vara en boolean',
zh: 'formatExclusiveMinimum 应当是布尔值'
},
if: {
en: 'should match "{{=e.params.failingKeyword}}" schema',
ru: 'должно соответствовать схемe "{{=e.params.failingKeyword}}"'
}
};

Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@
},
"homepage": "https://github.com/epoberezkin/ajv-i18n#readme",
"devDependencies": {
"ajv": "^5.1.5",
"ajv-keywords": "^2.1.0",
"ajv": "^6.0.0",
"ajv-keywords": "^3.0.0",
"brfs": "^1.4.3",
"browserify": "^14.1.0",
"coveralls": "^3.0.0",
"dot": "^1.0.3",
"eslint": "^4.9.0",
"eslint": "^4.15.0",
"js-beautify": "^1.7.4",
"json-schema-test": "^1.3.0",
"json-schema-test": "^2.0.0",
"karma": "^2.0.0",
"karma-mocha": "^1.3.0",
"karma-phantomjs-launcher": "^1.0.0",
Expand All @@ -60,7 +60,7 @@
"uglify-js": "^3.0.10"
},
"peerDependencies": {
"ajv": ">=5.0.0"
"ajv": "^6.0.0"
},
"nyc": {
"exclude": [
Expand Down
2 changes: 1 addition & 1 deletion spec/JSON-Schema-Test-Suite
1 change: 0 additions & 1 deletion spec/ajv
Submodule ajv deleted from 3760c3
28 changes: 22 additions & 6 deletions spec/localize.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ var remoteRefs = {
'http://localhost:1234/name.json': require('./JSON-Schema-Test-Suite/remotes/name.json')
};

var SKIP = {
'draft-04': ['optional/zeroTerminatedFloats'],
'draft-06': [],
'draft-07': [
'format/idn-email',
'format/idn-hostname',
'format/iri',
'format/iri-reference',
'optional/content'
]
};

var suites = testSuites();
for (var s in suites) runTests(s);

Expand All @@ -27,8 +39,8 @@ function runTests(suite) {

instances.forEach(function (ajv) {
addRemoteRefs(ajv);
if (suite != 'draft-06')
ajv._opts.defaultMeta = 'http://json-schema.org/draft-04/schema#';
if (suite != 'draft-07')
ajv._opts.defaultMeta = 'http://json-schema.org/' + suite + '/schema#';
});

var tests = {};
Expand All @@ -38,7 +50,7 @@ function runTests(suite) {
description: 'Schema tests of ' + instances.length + ' ajv instances with option i18n',
suites: tests,
afterEach: afterEach,
skip: suite == 'draft-04' ? ['optional/zeroTerminatedFloats'] : [],
skip: SKIP[suite],
assert: assert,
cwd: __dirname,
hideFolder: 'draft4/',
Expand All @@ -54,9 +66,11 @@ function getAjv(allErrors, verbose) {
patternGroups: true,
unknownFormats: ['allowedUnknown'],
allErrors: allErrors,
verbose: verbose
verbose: verbose,
schemaId: 'auto'
});
ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-04.json'));
ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-06.json'));
ajvKeywords(ajv, ['switch', 'patternRequired', 'formatMinimum', 'formatMaximum']);
ajv.addKeyword('constant', { macro: function(x) { return { const: x }; } });
return ajv;
Expand All @@ -69,18 +83,20 @@ function testSuites() {
_suites = {
'draft-04': require('./JSON-Schema-Test-Suite/tests/draft4/{**/,}*.json', {mode: 'list'}),
'draft-06': require('./JSON-Schema-Test-Suite/tests/draft6/{**/,}*.json', {mode: 'list'}),
'ajv tests': require('./ajv/spec/v5/*.json', {mode: 'list'})
'draft-07': require('./JSON-Schema-Test-Suite/tests/draft7/{**/,}*.json', {mode: 'list'})
};
for (var suiteName in _suites) {
_suites[suiteName].forEach(function(suite) {
if (suite.name.indexOf('optional/format') == 0)
suite.name = suite.name.replace('optional/', '');
suite.test = suite.module;
});
}
} else {
_suites = {
'draft-04': './JSON-Schema-Test-Suite/tests/draft4/{**/,}*.json',
'draft-06': './JSON-Schema-Test-Suite/tests/draft6/{**/,}*.json',
'ajv tests': './ajv/spec/v5/*.json'
'draft-07': './JSON-Schema-Test-Suite/tests/draft7/{**/,}*.json'
};
}
return _suites;
Expand Down

0 comments on commit a52e7f8

Please sign in to comment.