I have a JAX-RS resource in Quarkus whose inputs I want to validate. One of the properties in this validation bean below, which will validate the input from a PUT method, contains a property which is expected to be a number.
public class UpdateBookDTO {
public Optional<@Length(min = 2, max = 100) String> title;
public Optional<@Length(min = 2, max = 100) String> author;
public Optional<@Positive @Digits(fraction = 0, integer = 10) String> pages;
@Override
public String toString() {
return "UpdateBookDTO{" +
"title=" + title +
", author=" + author +
", pages=" + pages +
'}';
}
}
However, since the @Digits' annotation doesn't work with the Integer data type, I have to use a String. The issue with this of course is that it requires an extra step of parsing. Can I, and how, do this directly in the validation bean with some "magical" annotation, or is this not possible?
Thanks in advance!