Essentially, I'm trying to get something like this
public class Post {
public final @Nullable Optional<@Size(min = 10) String> title;
public Post(@JsonProperty("title") Optional<String> title) {
this.title = title;
}
}
but in Kotlin.
I've tried
class Post(
@field:Size(min = 10) val title: Optional<String>?
)
but that annotates the title property and not the String inside the Optional.
Is there a way to achieve this in Kotlin?
The context of this is to use validators in Spring Boot to validate the given string, if it is present. The Optional is there to allow me to distinguish between the user sending
{
"title": null
}
or
{}