@Min, @NotNull, etc)In a POST request the @Valid annotation must be triggered and show the errors of the restrictions set in the POJO class configured with lombok.
The @Valid annotation doesn't validate the class configured with lombok unless it has the getters set as you can see in the example below.
The User class does not have the getters set and @Valid does not trigger. On the other hand, the Pet class, having its getters, @Valid triggers the validation.
@alvarosanchez This is specific to Maven. It seems the annotation processor order is not respected. I created an equivalent gradle build and it works as expected.
The problem is this line: https://github.com/glats/lombok-validator-example/blob/master/pom.xml#L110
It must be:
<annotationProcessorPaths combine.self="override">
<path>
<!-- must precede micronaut-inject-java -->
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
<path>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-inject-java</artifactId>
<version>${micronaut.version}</version>
</path>
<path>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-validation</artifactId>
<version>${micronaut.version}</version>
</path>
<path>
<groupId>io.micronaut.openapi</groupId>
<artifactId>micronaut-openapi</artifactId>
<version>${micronaut.openapi.version}</version>
</path>
</annotationProcessorPaths>
Micronaut Launch generates the correct POM.
I see. Thank for your answer. However, is it possible to add this to the official documentation?
Sure. I created #4701