Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to describe a rule for a list of different objects? #33

Open
apenkov opened this issue Sep 14, 2019 · 3 comments
Open

How to describe a rule for a list of different objects? #33

apenkov opened this issue Sep 14, 2019 · 3 comments

Comments

@apenkov
Copy link

apenkov commented Sep 14, 2019

I am trying to describe an object of this kind:

{
    operations: [
        {
            properties:{
            	type:"1",
              	group: "11",
              	data:{data1:{},
                      data2:{}
                     }
            }
        },
        {
            properties:{
            	type:"2",
              	group: "12",
              	tools:["tools1","tools2"]
            }
        },
        {
            properties:{
            	type:"3",
              	group: "13",
              	objList:[{},{}]
            }
        },
        {
            properties:{
            	type:"4",
              	group: "14"
            }
        }
    ]
}

How can i use "variable_object" for such an object?

@apenkov
Copy link
Author

apenkov commented Sep 14, 2019

In general, can I validate the array as an ordered array, that is, set validation for each element?

@koorchik
Copy link
Owner

You can use different rules depending on type field. Here is an example

Does it solve the issue?

@apenkov
Copy link
Author

apenkov commented Sep 16, 2019

In this example, we specify the rules depending on the value of one of the fields,
but in the example above we have an array that consists of identical nested objects that differ only at the next level of nesting, and I can’t describe such an array

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

No branches or pull requests

2 participants