I need to annotate the `name` field of an enum. An...
# announcements
v
I need to annotate the
name
field of an enum. Any ideas how to do that? We are using a validation framework that is pretty strict and wont accept
ENUM_NAME
(underscore) from frontend, so I need to annotate the
name
-field of an enum to loosen up the validation.
g
I’m not completely sure, but you probably cannot. How you can do that in Java for example
v
In java
name
is a method, so it wont be validated, while in kotlin its a field.
g
But why do you want annotate it? How do you serialize enum?
v
The framework is checking all public fields and validating them. The way this is solved in our own DTOs is that we annotate the fields telling the validator which level of strictness we want on that field. The problem is that the public field
name
in a kotlin enum is validated and I have no way to tell the validator how it should validate it. I'll try to take another approach in solving this.