Skip to content

Commit

Permalink
fix: make sure to create the container path if it exists while null o…
Browse files Browse the repository at this point in the history
…r undefined
  • Loading branch information
logaretm committed Jun 3, 2021
1 parent 07aa09b commit 79d3779
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions 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';
Expand Down Expand Up @@ -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]) ? [] : {};
}
Expand Down

0 comments on commit 79d3779

Please sign in to comment.