This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
ValueObject for enums: how to properly validate? #13
Labels
discussion
Open-ended topics or questions, likely to be converted to a Github Discussion
Hi 👋,
Continuing on implementing my map project, let’s say I have this enum representing a map layer’s "type"/kind:
enum Type { raster, vector, geojson }
.If I wish to have some entity’s attribute be of that kind, as far as I understand (and based on trial/error), it cannot be simply typed as a
Type
but rather has to be wrapped in a value object — such as this one, although it seems "useless" (see inlined comments as to why):Is there a better way?
I feel like enums being sealed by design, having to come up with a dedicated value object is useless boilerplate, but maybe I’m missing something?
The text was updated successfully, but these errors were encountered: