Replies: 1 comment 5 replies
-
Nice, that sounds good to me. The validation has seemed a little inconsistent to me at times, so this would be a welcome change from my perspective.
Consistency is always good. For me, the most important things for a convenient validation response would be:
Let me know if my feedback does not apply to metadata validation, btw. I'm mostly basing this on the validation for dhis2 endpoints I've worked with in the past, and I can imagine that that does not translate 1-1 to metadata validation.
I would love that though, as a long term goal separate from this proposal. |
Beta Was this translation helpful? Give feedback.
-
This is an very early idea stage draft - mostly a collection of thoughts and ideas around a solution to make validation in DHIS2 more coherent and easier to understand and maintain.
Motivation
The main motivation is that the current metadata validation takes place on different levels using different patterns. This also provides much surface area for inconsistencies in the validation that takes place. It is mostly dependent upon the specific code path used to apply changes.
The majority of validations take place when using the importer, but there is also validation in service methods and controllers.
As the importer does not use services to do save/update or delete service level validation is passed by when using the importer.
The other way around when using the services importer validation is passed by. To make matters worse all validation is passed by when using the entity manager directly. This is more common than one might think as controllers at times use the entity manager to apply their changes after doing validation in the controller.
The reason such mixed patters did arise is that the validation used currently is tied with the operation. There is no way to do "importer validation" without doing an import or "service validation" without doing a save/update using the service. Frequently validation should occur before any actual manipulation is done which then is sometimes solved by adding validation to the controllers.
Goals
Non-Goals
This is a proposal specifically for metadata object validation.
Challenges
How to make sure validation always occurs?
Idea: Validation is hooked in on store level when running a store create/update/delete. As validation sometimes also needs to occur earlier in the overall operation the affected objects could get a
transient boolean validated
which the validation sets to true once the objects were validated. This way if validation had been applied the store skips the validation avoiding doing the same validation twice.Implementation
I made a draft PR to sketch the API https://github.com/dhis2/dhis2-core/pull/12103/files
Beta Was this translation helpful? Give feedback.
All reactions