1

I have a DTO, which is validated by Spring JSR validation, like this:

data class CreateDeckRequest(
    @field:NotBlank(message = "should not be blank!")
    val name: String?,
    @field:NotBlank(message = "should not be blank!")
    val techDesc: String?
    )

I am trying to reduce boilerplate and want my DTO to look like this:

data class CreateDeckRequest(
    @NotBlankApi
    val name: String?,
    @NotBlankApi
    val techDesc: String?
    )

To do that I want to create custom annotaion, which may look something like this:

@kotlin.annotation.Target(AnnotationTarget.FIELD)
@Retention(AnnotationRetention.RUNTIME)
@NotNull(message = "should not be blank!")
annotation class NotBlankApiField 

Is that semantically possible?

Thanks!

skidabee
  • 11
  • 1

0 Answers0