'Adding ACL for nested field object in JSON schema object
I am working on specify ACL fields for fields inside objects. I have the validator
to check for permission to edit a specific field. For example, the schema looks like this:
"basic_info": {
"properties": {
"cadi_id": {
...
},
"analysis_keywords": {
...
},
"abstract": {
"type": "string",
"title": "Abstract",
"acl": {
"users": ["[email protected]", "[email protected]"]
}
},
"ana_notes": {
...
},
"conclusion": {
...
}
},
"title": "Basic Information",
"type": "object",
"id": "basic_info",
"required": ["cadi_id"]
}
I have the abstract
field with acl. It works fine when the user(not in acl) is editing the abstract
field and the validation
error is thrown when the user is not in acl.
The problem comes when user(not in acl) is editing other field like conclusion
and have the same ValidationError
.
When editing any field in basic_info
, for example conclusion
field, the whole basic_info
object is processed in the validator beacuse it's the parent field and now user should be able to edit the conclusion
field because there is no acl set. but it gives the ValidationError
because we also receive the abstract
(which is unchanged) in the basic_info
and it goes to validate method and since the user is not in acl it gives ValidationError
.
Please let me know what I am missing here to let the user(not in acl) to edit the non acl field?
I tried to get the previous value from the db and check if the controlled field is edited by user or not, but it doesn't seems efficient for this use case and I want to know if there is any native way to do the field level validation. I could not find anything in the docs.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|