decaporg / decaporg/decap-cms

Nested validation bug with version 3.6.0

Open
#7,383 14 comments 1 reaction 0 assignees View on GitHub
type: bug
Dominant language
JavaScript
Stars
19.4k
Forks
3.1k
Avg merge
1d 14h
Merged PRs (30d)
9

Description

**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](https://github.com/user-attachments/assets/3999940e-7c45-4a5f-9849-8dc5c39d3815)

**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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.