Skip to content

Nested validation bug with version 3.6.0 #7383

@hip3r

Description

@hip3r

Describe the bug
object or list widgets, that are nested inside parent object widget don't pass validation anymore.
Object has all fields optional, but is detected as required.
Empty list is detected as invalid. Adding and removing one item solves issue and empty list is then detected as valid.

To Reproduce
config.yml settings for fields:

{name: usefulInfo, label: useful info, widget: object, i18n: true, collapsed: true, summary: '{{fields.title}}', fields: [
      {name: title, widget: string, i18n: true, required: false},
      {name: text, widget: markdown, minimal: true, required: false, editor_components: []},
      {name: button, widget: object, i18n: true, fields: [
        {name: text, widget: string, i18n: true, required: false},
        {name: href, widget: string, i18n: true, required: false},
      ]},
      {name: linksTitle, label: links title, widget: string, i18n: true, required: false},
      {name: links, widget: list, label_singular: link, i18n: true, fields: [{name: text, widget: string, i18n: true}, {name: href, widget: string, i18n: true}]},
    ]}

try saving entry with empty optional fields

Expected behavior

  • object with optional fields should be valid if empty.
  • empty list (of object that has required fields) should be valid

Screenshots
Image

Applicable Versions:

  • Decap CMS version: 3.6.0
  • Browser version: Chrome

CMS configuration

backend:
  name: test-repo

publish_mode: editorial_workflow
media_folder: assets/uploads
local_backend: true

collections:
  - name: pages # a nested collection
    label: Pages
    label_singular: 'Page'
    folder: _pages
    create: true
    nested: { depth: 100 }
    fields: [
     {name: usefulInfo, label: useful info, widget: object, i18n: true, collapsed: true, summary: '{{fields.title}}', fields: [
      {name: title, widget: string, i18n: true, required: false},
      {name: text, widget: markdown, minimal: true, required: false, editor_components: []},
      {name: button, widget: object, i18n: true, fields: [
        {name: text, widget: string, i18n: true, required: false},
        {name: href, widget: string, i18n: true, required: false},
      ]},
      {name: linksTitle, label: links title, widget: string, i18n: true, required: false},
      {name: links, widget: list, label_singular: link, i18n: true, fields: [{name: text, widget: string, i18n: true}, {name: href, widget: string, i18n: true}]},
    ]}]

Additional context
could be caused by #7374

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugcode to address defects in shipped code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions