@handy-tools/validator
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -117,2 +117,9 @@ var __defProp = Object.defineProperty; | ||
this.count++; | ||
const objectKeys = Object.keys(obj); | ||
const schemaKeys = Object.keys(schema); | ||
const incompatibleKeys = schemaKeys.filter((key) => !objectKeys.includes(key)); | ||
if (incompatibleKeys.length) { | ||
const errors2 = incompatibleKeys.map((key) => `Object is incompatible with scheme: hasn't this '${key}' field`); | ||
return { result: false, errors: errors2 }; | ||
} | ||
if (this.count > this.maxDepth) { | ||
@@ -119,0 +126,0 @@ throw new Error(` |
@@ -92,2 +92,9 @@ // src/constants.ts | ||
this.count++; | ||
const objectKeys = Object.keys(obj); | ||
const schemaKeys = Object.keys(schema); | ||
const incompatibleKeys = schemaKeys.filter((key) => !objectKeys.includes(key)); | ||
if (incompatibleKeys.length) { | ||
const errors2 = incompatibleKeys.map((key) => `Object is incompatible with scheme: hasn't this '${key}' field`); | ||
return { result: false, errors: errors2 }; | ||
} | ||
if (this.count > this.maxDepth) { | ||
@@ -94,0 +101,0 @@ throw new Error(` |
{ | ||
"name": "@handy-tools/validator", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "fancy validate objects", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js", |
29377
815