diff --git a/src/core/constants.js b/src/core/constants.js index fab71255ded9ea7861047730c5df501b0b5498b7..c27af463706e38b42a6ce205604961d8fba752e2 100644 --- a/src/core/constants.js +++ b/src/core/constants.js @@ -1,4 +1,5 @@ -const ALL_TYPES = ['array', 'object', 'integer', 'number', 'string', 'boolean', 'null']; +const SCALAR_TYPES = ['integer', 'number', 'string', 'boolean', 'null']; +const ALL_TYPES = ['array', 'object'].concat(SCALAR_TYPES); const MOST_NEAR_DATETIME = 2524608000000; @@ -9,6 +10,7 @@ const MIN_NUMBER = -100; const MAX_NUMBER = 100; export default { + SCALAR_TYPES, ALL_TYPES, MIN_NUMBER, MAX_NUMBER, diff --git a/src/core/traverse.js b/src/core/traverse.js index 0c49caba3daf8d029e6805db12eba4cf1e5b68c2..32135b121c4a83f4edb5340e96c9d6c4f93652d9 100644 --- a/src/core/traverse.js +++ b/src/core/traverse.js @@ -37,6 +37,11 @@ function traverse(schema, path, resolve, rootSchema) { if (schema.not && typeof schema.not === 'object') { schema = utils.notValue(schema.not, utils.omitProps(schema, ['not'])); + + // build new object value from not-schema! + if (schema.type && schema.type === 'object') { + return traverse(schema, path.concat(['not']), resolve, rootSchema); + } } if ('const' in schema) { diff --git a/src/core/utils.js b/src/core/utils.js index a3f6cb92ca4bfd06434d5136757a49292536ae73..6d46d56d315854d6681799ce55d0ba58f587e847 100644 --- a/src/core/utils.js +++ b/src/core/utils.js @@ -265,7 +265,7 @@ function notValue(schema, parent) { } if (schema.type) { - copy.type = random.pick(env.ALL_TYPES.filter(x => { + copy.type = random.pick(env.SCALAR_TYPES.filter(x => { const types = Array.isArray(schema.type) ? schema.type : [schema.type]; return types.every(type => { diff --git a/src/types/object.js b/src/types/object.js index 7d6a72036ca60e78b309f5099b6e74e584a6460a..e6f1849807a55e504194a6214d1455a0ef36fbc6 100644 --- a/src/types/object.js +++ b/src/types/object.js @@ -33,7 +33,7 @@ function objectType(value, path, resolve, traverseCallback) { && utils.hasProperties(value, 'minProperties', 'maxProperties', 'dependencies', 'required') ) { // just nothing - return {}; + return null; } if (optionAPI('requiredOnly') === true) { diff --git a/tests/schema/core/types/not.json b/tests/schema/core/types/not.json index 20d7c6b4dcdb72ad1017b1adaf11332d7393fe45..a49fe92a6b0647179ab2a5cacad72a47b269848f 100644 --- a/tests/schema/core/types/not.json +++ b/tests/schema/core/types/not.json @@ -28,7 +28,6 @@ "notBoolean" ] }, - "skip": true, "valid": true }, {