Hi, I am trying to compose my domain model for my...
# getting-started
j
Hi, I am trying to compose my domain model for my new project and use value classes at some places. I have run into the problem that annotations from the value class attributes are lost at runtime.
Copy code
class Test(

    @field:Valid
	val inlinedMember: InlinedMember,

	@field:Valid
	val normalMember: NormalMember,
)

@JvmInline
value class InlinedMember constructor(
	@field:NotBlank
	val subAttr: String
)

class NormalMember constructor(
	@field:NotBlank
	val subAttr: String
)
After I compile this code and run it, the property inlinedMember of the class Test is replaces with the type String and the annotation @field:NotBlank is lost, resulting in the validator not validating this constrain. Has anyone an idea how to keep the information (without copying it) or what else to do? The goal is to use the same value class (e.g. email, bithdate, username,..) at several places and only define the constrains once. This is a spring boot project, using jackson to parse and validate the JSON data on the REST controller
👋 2
Is there a way to hook into the compilation step, to copy the annotations from the inline value class to the attribute?