From 8f95bb3975b6c4bcb39dbf46defd32c47e157b28 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alvaro=20Cabrera=20Dur=C3=A1n?= <pateketrueke@gmail.com>
Date: Wed, 9 Oct 2019 22:31:05 -0500
Subject: [PATCH] Handle not-schema values on pending tests; cleanup

---
 src/core/constants.js            | 4 +++-
 src/core/traverse.js             | 5 +++++
 src/core/utils.js                | 2 +-
 src/types/object.js              | 2 +-
 tests/schema/core/types/not.json | 1 -
 5 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/core/constants.js b/src/core/constants.js
index fab71255..c27af463 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 0c49caba..32135b12 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 a3f6cb92..6d46d56d 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 7d6a7203..e6f18498 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 20d7c6b4..a49fe92a 100644
--- a/tests/schema/core/types/not.json
+++ b/tests/schema/core/types/not.json
@@ -28,7 +28,6 @@
             "notBoolean"
           ]
         },
-        "skip": true,
         "valid": true
       },
       {
-- 
GitLab