Skip to content

Updated to vee-validate 4.8.0: App throws "Cannot set properties of undefined" #4186

@ahoiroman

Description

@ahoiroman

What happened?

Givent this custom form:

<template>
    <input v-model="value"
           v-bind="$attrs"/>
</template>
<script setup lang="ts">
import {useField} from 'vee-validate';

interface Props {
    name: string;
    modelValue?: string;
    waiting?: boolean,
    disabled?: boolean
}

const props = withDefaults(defineProps<Props>(), {
    waiting: false,
    disabled: false,
    modelValue: ''
});

const nameRef = toRef(props, 'name');
const {
    value,
    errorMessage,
    meta,
} = useField(nameRef, undefined);
</script>

This worked out fine in eve-validate < 4.8.0, but now throws:

value cannot be made reactive: undefined
[Vue warn]: Unhandled error during execution of setup function 
  at <InputStringBase modelValue=undefined onUpdate:modelValue=fn<onUpdate:modelValue> name="name"  ... >
[nuxt] error caught during app initialization TypeError: Cannot set properties of undefined (setting 'name')
    at setInPath (/Users/ahoiroman/Entwicklung/nuxtjs/nuxt-project/.output/server/node_modules/vee-validate/dist/vee-validate.js:325:30)
    at Object.stageInitialValue (/Users/ahoiroman/Entwicklung/nuxtjs/nuxt-project/.output/server/node_modules/vee-validate/dist/vee-validate.js:2082:13)
    at _useFieldValue (/Users/ahoiroman/Entwicklung/nuxtjs/nuxt-project/.output/server/node_modules/vee-validate/dist/vee-validate.js:962:14)
    at useFieldState (/Users/ahoiroman/Entwicklung/nuxtjs/nuxt-project/.output/server/node_modules/vee-validate/dist/vee-validate.js:899:58)
    at _useField (/Users/ahoiroman/Entwicklung/nuxtjs/nuxt-project/.output/server/node_modules/vee-validate/dist/vee-validate.js:1045:83)
    at useField (/Users/ahoiroman/Entwicklung/nuxtjs/nuxt-project/.output/server/node_modules/vee-validate/dist/vee-validate.js:1037:16)
    at setup (file:///Users/ahoiroman/Entwicklung/nuxtjs/nuxt-project/.output/server/chunks/app/_application/BaseButton-e84c286f.mjs:22:9)
    at _sfc_main$2.setup (file:///Users/ahoiroman/Entwicklung/nuxtjs/nuxt-project/.output/server/chunks/app/_application/BaseButton-e84c286f.mjs:42:25)
    at callWithErrorHandling (/Users/ahoiroman/Entwicklung/nuxtjs/nuxt-project/.output/server/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:171:22)
    at setupStatefulComponent (/Users/ahoiroman/Entwicklung/nuxtjs/nuxt-project/.output/server/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7194:29) {
  statusCode: 500,
  fatal: false,
  unhandled: false,
  statusMessage: undefined,
  __nuxt_error: true
}

Reproduction steps

No response

Version

Vue.js 3.x and vee-validate 4.x

What browsers are you seeing the problem on?

  • Firefox
  • Chrome
  • Safari
  • Microsoft Edge

Relevant log output

No response

Demo link

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 bugUnintended behavior

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions