Skip to content

a top-level array as initialValue is corrupted #5148

@fembau

Description

@fembau

What happened?

I want to use a schema with an array as top-level structure.

Works in v4 but, in v5 the initial value (=array) is somehow converted to an object with index as keys.

actual value:

{
  "0": {
    "field1": "field1",
    "field2": "field2"
  }
}

expected value:

[
  {
    "field1": "field1",
    "field2": "field2"
  }
]

I figured out that I can use "." as name for the top-level array. If this is the proper way to do it please add this in the documentation. Didn't found it here.

<FieldArray name="." #default="{ fields }">

Reproduction steps

  • use an initial value with an array as top-level structure

Version

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

What browsers are you seeing the problem on?

  • Firefox
  • Chrome
  • Safari
  • Microsoft Edge

Relevant log output

Demo link

https://stackblitz.com/edit/vee-validate-issue-template-pzg7lfwl?file=src%2FApp.vue

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions