# Field validation in a set

**URL:** <https://discourse.getcockpit.com/t/field-validation-in-a-set/1672>\
**Category:** Support\
**Created:** [October 8, 2020, 10:06am UTC](https://discourse.getcockpit.com/t/field-validation-in-a-set/1672 "2020-10-08T10:06:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tommueller](https://avatars.discourse-cdn.com/v4/letter/t/aca169/32.png) [@tommueller](https://discourse.getcockpit.com/u/tommueller)\
**Post date:** [October 8, 2020, 10:06am UTC](https://discourse.getcockpit.com/t/field-validation-in-a-set/1672/1 "2020-10-08T10:06:33Z")

</div>

Is it correct, that field validation, does not work in sets? I have a Repeater-field which itself contains a set of other fields. This is all working fine, but I cannot seem to validate the fields within the set.

```auto
{
  "field": {
    "type": "set",
    "options": {
      "fields": [
        {
          "name": "text",
          "label": "Text",
          "maxlength": "200",
          "required": true,
          "type": "text"
        },
        ...
      ]
    }
  }
}

```

Neither shows me an error when the field is empty, nor when I enter more then 200 characters.

Is there no possibility to validate fields listed in a Set?

---

<div class="post-metadata">

**Author:** ![raffaelj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/raffaelj/32/331_2.png) [@raffaelj](https://discourse.getcockpit.com/u/raffaelj)\
**Post date:** [October 8, 2020, 2:07pm UTC](https://discourse.getcockpit.com/t/field-validation-in-a-set/1672/2 "2020-10-08T14:07:47Z")

</div>

I’m not sure right now, if validation works inside sets and repeaters - but if or if not, you have to adjust your field options a little bit so the nested fields receive their options properly:

```json
{
  "field": {
    "type": "set",
    "options": {
      "fields": [
        {
          "name": "text",
          "label": "Text",
          "type": "text",
          "options": { // <-- nested field options
            "maxlength": "200",
            "required": true,
          }
        },
        ...
      ]
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![tommueller](https://avatars.discourse-cdn.com/v4/letter/t/aca169/32.png) [@tommueller](https://discourse.getcockpit.com/u/tommueller)\
**Post date:** [October 8, 2020, 5:56pm UTC](https://discourse.getcockpit.com/t/field-validation-in-a-set/1672/3 "2020-10-08T17:56:17Z")

</div>

As always spot on. Thanks!

---

<div class="post-metadata">

**Author:** ![dhanjiv](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@dhanjiv](https://discourse.getcockpit.com/u/dhanjiv)\
**Post date:** [April 9, 2021, 8:36am UTC](https://discourse.getcockpit.com/t/field-validation-in-a-set/1672/4 "2021-04-09T08:36:30Z")

</div>

> Field validation does not work in sets of fields in repeater?

{  
“fields”: [  
{  
“type”: “set”,  
“label”: “Category”,  
“options”: {  
“display”: “name”,  
“fields”: [  
{  
“name”: “parentName”,  
“type”: “text”,  
“label”: “Parent name”  
},  
{  
“name”: “categoryName”,  
“type”: “text”,  
“label”: “Category”,  
“options”: {  
“required”: true  
}  
},  
{  
“name”: “categoryNote”,  
“type”: “textarea”,  
“label”: “Note”  
},  
{  
“name”: “categoryOrder”,  
“type”: “text”,  
“label”: “Order”,  
“options”: {  
“type”: “number”,  
“rows”: 2  
}  
},  
{  
“name”: “categoryImg”,  
“type”: “image”,  
“label”: “Image”  
}  
]  
}  
}  
]  
}
