Given this controller method.
import io.micronaut.validation.Validated;
...
@Validated
@Get(value = "test{?page*}", produces = APPLICATION_JSON)
public HttpResponse<TransactionListResponseDto> get(
PageDto page) {
Sort sort = Pageable.from(page.getPage(), page.getSize(), sortFrom(page.getSort()));
return HttpResponse.ok();
}
and the PageDto that looks like this.
import javax.validation.constraints.Min;
...
@Getter
@Setter
@Introspected
@JsonInclude(NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class PageDto {
@Min(1)
private int page = 1;
private int size = 10;
private String sort;
}
and the necessary validation includes in the gradle file.
implementation "io.micronaut:micronaut-validation:$micronautVersion"
implementation "io.micronaut.beanvalidation:micronaut-hibernate-validator:$micronautVersion"
I am expecting that controller method to validate the arguments, but it's very happy for me to pass in (for example) -100 as the page number, despite the validation attributes.
Following the documentation and advice.
I have to conclude I am missing a build step or something?