[Feature request] Add options to support nested groups for non anonymous fields
Hi !
All in the title, it can be great to have an option to recursively apply groups on childs when the field is an Struct.
For example, there might be an account with an associated account. The person can see all details of their own account but not all details of the child accounts.
type User struct {
UserBasicInfo `groups:"basic"`
UserPrivateInfo `groups:"secret"`
Children []User `groups:"basic"`
}
type UserBasicInfo struct {
ID string
Email string
}
type UserPrivateInfo struct {
Secret string
}
Then as a parent I will see:
{
"ID": "43",
"Email": "[email protected]",
"Secret": "I cannot see my children's secrets. I only see my own secrets,",
"Children": [
{
"ID": "44",
"Email": "[email protected]"
}
]
}
But as a child I will see:
{
"ID": "44",
"Email": "[email protected]",
"Secret": "I see my own secret"
}
Currently this will not work because there are already groups on the User struct (the parent will see the child's secrets). Basically would just need a way to override the existing groups of nested groups.
I see the use case but currently don't have enough time to work on this. I'd be happy to review a PR with including tests.
I'd probably make this feature optional or even that you could define it per field.
Closing as not planned currently.