From 79d37798ccf2fef56714bdad4db553086df0ad48 Mon Sep 17 00:00:00 2001 From: Abdelrahman Awad Date: Thu, 3 Jun 2021 20:28:27 +0200 Subject: [PATCH] fix: make sure to create the container path if it exists while null or undefined --- packages/vee-validate/src/utils/common.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/vee-validate/src/utils/common.ts b/packages/vee-validate/src/utils/common.ts index eb36eb7f4..2aac73425 100644 --- a/packages/vee-validate/src/utils/common.ts +++ b/packages/vee-validate/src/utils/common.ts @@ -1,4 +1,4 @@ -import { isIndex, isObject } from '../../../shared'; +import { isIndex, isNullOrUndefined, isObject } from '../../../shared'; import { getCurrentInstance, inject, InjectionKey, warn as vueWarning } from 'vue'; import { isContainerValue, isEmptyContainer, isNotNestedPath } from './assertions'; import { PrivateFieldComposite } from '../types'; @@ -58,7 +58,7 @@ export function setInPath(object: NestedRecord, path: string, value: unknown): v } // Key does not exist, create a container for it - if (!(keys[i] in acc)) { + if (!(keys[i] in acc) || isNullOrUndefined(acc[keys[i]])) { // container can be either an object or an array depending on the next key if it exists acc[keys[i]] = isIndex(keys[i + 1]) ? [] : {}; }