# Rules for nested properties

**URL:** <https://jsonforms.discourse.group/t/rules-for-nested-properties/343>\
**Category:** General\
**Created:** [August 13, 2021, 8:52am UTC](https://jsonforms.discourse.group/t/rules-for-nested-properties/343 "2021-08-13T08:52:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![adam.cernohorsky](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@adam.cernohorsky](https://jsonforms.discourse.group/u/adam.cernohorsky)\
**Post date:** [August 13, 2021, 8:52am UTC](https://jsonforms.discourse.group/t/rules-for-nested-properties/343/1 "2021-08-13T08:52:54Z")

</div>

Hi,

Im trying to solve my issue with HIDE rule in simple jsonSchema.

**JSON SCHEMA:**

```auto
{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "properties": {
        "component": {
            "type": "object",
            "properties": {
                "class": {
                    "type": "string"
                },
                "variant": {
                    "type": "string",
                    "enum": ["YES_NO", "ARROW"]
                },
                "backgroundColor": {
                    "type": "string"
                },
                "backgroundColorDark": {
                    "type": "string"
                }
            }
        },
        "title": {
            "type": "object",
            "properties": {
                "text": {
                    "type": "string"
                },
                "textColor": {
                    "type": "string"
                },
                "textColorDark": {
                    "type": "string"
                }
            },
            "required": ["text"]
        },
        "links": {
            "type": "object",
            "properties": {
                "noLink": {
                    "type": "string"
                },
                "noLinkImageAlt": {
                    "type": "string"
                },
                "yesLink": {
                    "type": "string"
                },
                "yesLinkImageAlt": {
                    "type": "string"
                },
                "arrowLink": {
                    "type": "string"
                },
                "arrowLinkImageAlt": {
                    "type": "string"
                }
            }
        }
    },
    "required": ["component", "title", "links"]
}

```

**UI SCHEMA:**

```auto
{
    "type": "VerticalLayout",
    "elements": [
        {
            "type": "Group",
            "elements": [
                {
                    "type": "Control",
                    "scope": "#/properties/component/properties/variant"
                },
                {
                    "type": "Control",
                    "scope": "#/properties/links/properties/arrowLink",
                    "rule": {
                        "effect": "HIDE",
                        "condition": {
                            "scope": "#/properties/component/properties/variant",
                            "schema": { "enum": ["YES_NO"] }
                        }
                    }
                }
            ]
        }
    ]
}

```

The goal is to HIDE arrowLink when is selected YES\_NO variant. I was reading your docs, these topics but I have not found any suitable solution.

Please if you could help me what is wrong with my rule in UI schema.

Thank you a lot!  
Adam

---

<div class="post-metadata">

**Author:** ![sdirix](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/sdirix/32/1073_2.png) [@sdirix](https://jsonforms.discourse.group/u/sdirix)\
**Post date:** [August 13, 2021, 9:12am UTC](https://jsonforms.discourse.group/t/rules-for-nested-properties/343/2 "2021-08-13T09:12:14Z")

</div>

Hi @adam.cernohorsky, your schema and ui schema work fine for me with the JSON Forms React Material renderers.

![HideYesNo](https://global.discourse-cdn.com/free1/uploads/jsonforms/original/1X/1ed47b7ad8ed6b7fd8d09882286d1740c899abe3.gif)

Which renderer set are you using and what exactly does not work for you?

---

<div class="post-metadata">

**Author:** ![adam.cernohorsky](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@adam.cernohorsky](https://jsonforms.discourse.group/u/adam.cernohorsky)\
**Post date:** [August 13, 2021, 9:35am UTC](https://jsonforms.discourse.group/t/rules-for-nested-properties/343/3 "2021-08-13T09:35:20Z")

</div>

Hi, thank you for fast reply!,

I am using only default renderers as you:

```auto
const renderers = [...materialRenderers];

    return (
        <>
            <JsonForms
                schema={jsonSchema}
                data={formResult}
                renderers={renderers}
                cells={materialCells}
                onChange={({ data }) => dispatch(setFormResult(data))}
            />
        </>
    );

```

And also having these versions:

```auto
"@jsonforms/core": "^2.5.2",
"@jsonforms/material-renderers": "^2.5.2",
"@jsonforms/react": "^2.5.2",

```

Is it possible that it might be caused because of bad versions? I have try this for many times but the filed is still visible, which does not make me sense.

Here is picture how my form look like:

 ![Capture](https://global.discourse-cdn.com/free1/uploads/jsonforms/original/1X/60cff0c471505a2f7eb07c5d5219979388c7e935.png)

---

<div class="post-metadata">

**Author:** ![sdirix](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/sdirix/32/1073_2.png) [@sdirix](https://jsonforms.discourse.group/u/sdirix)\
**Post date:** [August 13, 2021, 11:08am UTC](https://jsonforms.discourse.group/t/rules-for-nested-properties/343/4 "2021-08-13T11:08:12Z")

</div>

Hi @adam.cernohorsky, in the example code no ui schema is handed over to JSON Forms, therefore a default ui schema is generated and used. Can you make sure that you hand over your ui schema?

Not related to the issue but you should make sure to not hand over unnecessary new instances to JSON Forms. The anonymous function in `onChange` is fine as we can detect that but for example the renderers should be not newly created with each render call. So either move them out of the component or place them in a `useMemo` to increase performance.

---

<div class="post-metadata">

**Author:** ![adam.cernohorsky](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@adam.cernohorsky](https://jsonforms.discourse.group/u/adam.cernohorsky)\
**Post date:** [August 13, 2021, 11:33am UTC](https://jsonforms.discourse.group/t/rules-for-nested-properties/343/5 "2021-08-13T11:33:15Z")

</div>

omg… I am so stupid… 🤦‍♀️

I spend hours with fixing the UI schema and I have not use it…

Sorry for wasting your time, now everything works perfectly as I expected. Thank you!

---

<div class="post-metadata">

**Author:** ![sdirix](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/sdirix/32/1073_2.png) [@sdirix](https://jsonforms.discourse.group/u/sdirix)\
**Post date:** [August 13, 2021, 11:53am UTC](https://jsonforms.discourse.group/t/rules-for-nested-properties/343/6 "2021-08-13T11:53:21Z")

</div>

Don’t worry, happens to the best of us 😉
