decaporg / decaporg/decap-cms

Validation fails when optional object field has required fields

Open
#7,748 4 comments 0 reactions 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

I think this similar but not the same as #7383

**Describe the bug**

When an `object` field is optional but has a required field, it fails validation when all its fields are empty.

**To Reproduce**

Add this field to a collection:

```yaml
- name: submittedBy
label: Submitted by
widget: object
summary: '{{fields.name}}'
required: false
i18n: false
fields:
- name: name
label: Name
widget: string
- name: url
label: Url (separate multiple entries with a comma)
widget: list
required: false
```

Try to save an item without setting `submittedBy.name`

**Expected behavior**

Validation should pass, and item be saved without `subittedBy`

**Screenshots**

Instead:

Image

**Applicable Versions:**

- Decap CMS version: 3.9.0

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.