# Help with validation on nested array

**URL:** <https://discourse.aurelia.io/t/help-with-validation-on-nested-array/3071>\
**Category:** Help Requests\
**Created:** [November 19, 2019, 8:37pm UTC](https://discourse.aurelia.io/t/help-with-validation-on-nested-array/3071 "2019-11-19T20:37:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pmarchio](https://avatars.discourse-cdn.com/v4/letter/p/48db29/32.png) [@pmarchio](https://discourse.aurelia.io/u/pmarchio)\
**Post date:** [November 19, 2019, 8:37pm UTC](https://discourse.aurelia.io/t/help-with-validation-on-nested-array/3071/1 "2019-11-19T20:37:35Z")

</div>

I am trying to add a rule on an array element and see from searching around that this may not be supported. Everything else works but adding a rule on the array item throws the following error:

Error: Unable to parse accessor function:  
function (e) {  
return e.buttonURL[0];

Below is a condensed code snippet, objectToAdd is spliced onto the main array.

```
articleElements = [];

objectToAdd = {
    text: "",
    buttonURL: [{ value: "" }, { value: "" }, { value: "" }, { value: "" }, { value: "" }]
};

this.articleElements.splice(this.articleElements[0], 0, this.objectToAdd);

        this.articleElementRules = ValidationRules
        .ensure(e => e.text).required()
        .withMessage('missing field')
        **.ensure((e) => e.buttonURL[0]).required()**
        .withMessage('missing field')

```

The view consists of a repeat.for=“articleElement of articleElements”

and

…

```
               <div class="input-field">
             <input value.two-way="articleElement.buttonURL[0].value & validate:articleElementsValidation" type="text">
          </div>
```

---

<div class="post-metadata">

**Author:** ![Sayan751](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/sayan751/32/1861_2.png) [@Sayan751](https://discourse.aurelia.io/u/Sayan751)\
**Post date:** [November 20, 2019, 8:24am UTC](https://discourse.aurelia.io/t/help-with-validation-on-nested-array/3071/2 "2019-11-20T08:24:14Z")

</div>

AFAIK the `.ensure((e) => expr)` only supports `expr` in the form `obj.prop`. The other patterns such as `obj.prop.subprop`, or `obj.array[index]` is not yet supported. However, a string expression should work as per my knowledge, for example: `.ensure('obj.prop.subprop')`.
