diia-open-source / be-user-service

European Union Public License 1.2
136 stars 7 forks source link

Add Enum for Schema Field Value Constraints #69

Closed aleksandr-sosedskyi closed 6 months ago

aleksandr-sosedskyi commented 6 months ago

This pull request adds missed enum to enforce strict constraints on the possible values of Schema fields. It ensures that only valid values are accepted, reducing the potential for errors.

ghost commented 6 months ago

The user-service repo is unaware of specific enum values of doc status, doc subtype, and so on in an overall system. These values are imported from the types package, which could be stale compared to the actual types state in a newer package version. At the same time, another repo (e.g., documents-service) could use this newer types package and produce new enum values for the user-service, and it will be wrong if we add these new constraints: requests will fail. The user service doesn't need to know about every new enum value, it's a kind of agnostic approach.

Logically, the next question would be why we are using these enums in user-service types then, and the answer is maybe we shouldn't :) Our team has no problems with this, but it will undoubtedly be done during our migration to the gRPC setup.