Skip to content

Commit

Permalink
refactor: return boolean schema true instead of empty schema {}
Browse files Browse the repository at this point in the history
  • Loading branch information
epoberezkin committed Feb 10, 2019
1 parent f261c0c commit 8350454
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions keywords/anyRequired.js
Expand Up @@ -4,12 +4,12 @@ module.exports = function defFunc(ajv) {
defFunc.definition = {
type: 'object',
macro: function (schema) {
if (schema.length == 0) return {};
if (schema.length == 1) return { required: schema };
if (schema.length == 0) return true;
if (schema.length == 1) return {required: schema};
var schemas = schema.map(function (prop) {
return { required: [prop] };
return {required: [prop]};
});
return { anyOf: schemas };
return {anyOf: schemas};
},
metaSchema: {
type: 'array',
Expand Down
2 changes: 1 addition & 1 deletion keywords/deepProperties.js
Expand Up @@ -9,7 +9,7 @@ module.exports = function defFunc(ajv) {
var schemas = [];
for (var pointer in schema)
schemas.push(getSchema(pointer, schema[pointer]));
return { 'allOf': schemas };
return {'allOf': schemas};
},
metaSchema: {
type: 'object',
Expand Down
8 changes: 4 additions & 4 deletions keywords/prohibited.js
Expand Up @@ -4,12 +4,12 @@ module.exports = function defFunc(ajv) {
defFunc.definition = {
type: 'object',
macro: function (schema) {
if (schema.length == 0) return {};
if (schema.length == 1) return { not: { required: schema } };
if (schema.length == 0) return true;
if (schema.length == 1) return {not: {required: schema}};
var schemas = schema.map(function (prop) {
return { required: [prop] };
return {required: [prop]};
});
return { not: { anyOf: schemas } };
return {not: {anyOf: schemas}};
},
metaSchema: {
type: 'array',
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -31,10 +31,10 @@
},
"homepage": "https://github.com/epoberezkin/ajv-keywords#readme",
"peerDependencies": {
"ajv": "^6.0.0"
"ajv": "^6.9.1"
},
"devDependencies": {
"ajv": "^6.8.1",
"ajv": "^6.9.1",
"ajv-pack": "^0.3.0",
"chai": "^4.2.0",
"coveralls": "^3.0.2",
Expand Down

0 comments on commit 8350454

Please sign in to comment.