From 13f96399e9351c01bd7cfaa1a695decd51420e92 Mon Sep 17 00:00:00 2001 From: Robert Snedeker Date: Wed, 28 Aug 2024 14:52:05 -0400 Subject: [PATCH] build package --- dist/index.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dist/index.js b/dist/index.js index 672a8eb..de163b2 100644 --- a/dist/index.js +++ b/dist/index.js @@ -8,11 +8,16 @@ function validate(objectToValidate, config) { hasErrors: false }; const pushError = (field, message, bag = null) => { - var _a; - var _b; + var _a, _b; + var _c, _d; bag !== null && bag !== void 0 ? bag : (bag = errorBag); - (_a = (_b = bag.errors)[field]) !== null && _a !== void 0 ? _a : (_b[field] = []); + (_a = (_c = bag.errors)[field]) !== null && _a !== void 0 ? _a : (_c[field] = []); if (!(bag.errors[field] instanceof Array)) { + (_b = (_d = bag.errors[field]).errors) !== null && _b !== void 0 ? _b : (_d.errors = []); + if (!(bag.errors[field].errors instanceof Array)) { + throw new Error(`Errors field name is reserved when using nested validation with top level validation!`); + } + bag.errors[field].errors.push(message); return; } bag.errors[field].push(message);