Skip to content

fix nested behave for JsonRepeatable - #27

Open
KotenkoSerge wants to merge 2 commits into
stepanenko3:mainfrom
KotenkoSerge:main
Open

KotenkoSerge wants to merge 2 commits into
stepanenko3:mainfrom
KotenkoSerge:main

Conversation

@KotenkoSerge

@KotenkoSerge KotenkoSerge commented Jan 8, 2025

Copy link
Copy Markdown

Found that JsonRepeatable behave incorect when it has nested structure. Let's take a look at request example:

"json_repeatable": 
    [
        {
            "title": "Title 1",
            "badge": "badge 1",
            "nested_json_repeatable": [
                {
                    "uuid": "891e1a21-c655-40c2-9026-7e2c7b52b285",
                    "title": "nested 1 title 1",
                    "url": "http://localhost/1_1",
                    "description": "Description 1"
                },
                {
                    "uuid": "ef20be68-7510-4455-9a39-67185005fe34",
                    "title": "nested 1 title 2",
                    "url": "http://localhost/1_2",
                    "description": "Description 2"
                }
            ]
        },
        {
            "title": "Title 2",
            "nested_json_repeatable": [
                {
                    "uuid": "9c324bee-c55d-40e5-a7a0-55b2ac6ac752",
                    "title": "nested 2 title 2",
                    "url": "http://localhost/2_2",
                    "description": "Description 2"
                }
            ]
        }
    ]

So what did I found is that JsonRepeatable does not fill values field by field when JsonRepeatable is inside other JsonRepeatable, it directly takes whole array from request by key (nested_json_repeatable from my example) and put it to model's value without any validation as validation rules also broken when JsonRepeatable is nested.
This merge request adds, I would call it, "pseudo" recursion for nested JsonRepeatable and nested rules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants