webiny-js icon indicating copy to clipboard operation
webiny-js copied to clipboard

CMS: Validation and pre-defined values check doesn't work for fields inside an object field

Open Ashu96 opened this issue 3 years ago • 2 comments

Version

5.18.3

Operating System

MacOS

Browser

Chrome

What steps will reproduce the bug?

Create a content model with few field with predefined values and validators inside an object field.

For example, here is a definition of such a model:

{
          "name": "Workflow",
          "modelId": "workflow",
          "fields": [
            {
              "label": "Title",
              "type": "text",
              "multipleValues": false,
              "predefinedValues": {
                "enabled": false,
                "values": []
              },
              "settings": {}
            },
            {
              "label": "App",
              "type": "text",
              "multipleValues": false,
              "predefinedValues": {
                "enabled": true,
                "values": [
                  {
                    "label": "Page Builder",
                    "value": "pageBuilder"
                  },
                  {
                    "label": "CMS",
                    "value": "cms"
                  }
                ]
              },
              "settings": {}
            },
            {
              "label": "Scope",
              "type": "object",
              "multipleValues": false,
              "predefinedValues": {
                "enabled": false,
                "values": []
              },
              "settings": {
                "fields": [
                  {
                    "renderer": {
                      "name": "select-box"
                    },
                    "predefinedValues": {
                      "enabled": true,
                      "values": [
                        {
                          "value": "default",
                          "label": "Default"
                        },
                        {
                          "value": "pb",
                          "label": "Page Builder"
                        },
                        {
                          "value": "cms",
                          "label": "CMS"
                        }
                      ]
                    },
                    "label": "Type",
                    "id": "33wJFMsY5",
                    "type": "text",
                    "validation": [
                      {
                        "name": "required",
                        "message": "Value is required."
                      }
                    ],
                    "fieldId": "type"
                  }
                ],
                "layout": [
                  [
                    "33wJFMsY5"
                  ]
                ]
              }
            }
          ]
        }

Then try creating few entries via API and you will see:

  1. No validation error for empty values: image

  2. No validation error even when we input random values instead of pre-defined ones: image

What is the expected behavior?

Nested fields that are inside an object field should be validated as any other field. For example,

image

What do you see instead?

No response

Additional information

No response

Possible solution

No response

Ashu96 avatar Dec 14 '21 12:12 Ashu96

This issue is stale because it was opened 120 days with no activity. Remove the "stale-issue" label or leave a comment to revive the issue. Otherwise, it will be closed in 7 days.

webiny-bot avatar Apr 16 '22 07:04 webiny-bot

This issue is stale because it was opened 120 days with no activity. Remove the "stale-issue" label or leave a comment to revive the issue. Otherwise, it will be closed in 7 days.

webiny-bot avatar Aug 15 '22 07:08 webiny-bot