-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Micronaut Validation documentation incorrect statement about @Introspected #232
Comments
Suppose we generate a Micronaut application (Java 17+Maven) with the following features: validation, serialization-jackson, lombok, http-client, then add these classes: package org.acme.model;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data;
@Data
public class Product {
@NotEmpty
private String name;
private int id;
} We add also a validated controller: package org.acme;
import io.micronaut.http.annotation.Body;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Post;
import jakarta.validation.Valid;
import org.acme.model.Product;
@Controller("/product")
public class ProductsController {
@Post
public String addProduct(@Valid @Body Product product) {
return String.format("added product %s", product);
}
} Start the application with
I have a few remarks:
So fixing the error should be straightforward: annotate the class with
When we use the annotation
ConclusionThe section 5 of Validation docs is indeed incorrect with respect to point 1 (it should have mentioned |
Expected Behavior
Validation documentation shouldn't state that @introspected annotation is required for validation.
Actual Behaviour
Current Micronaut Validation documentation (https://micronaut-projects.github.io/micronaut-validation/snapshot/guide/) states that:
To validate data classes, e.g. POJOs (typically used in JSON interchange), the class must be annotated with @Introspected (see Micronaut Guide Introspection section) or, if the class is external, be imported by the @introspected annotation.
However that's not true as per Micronaut 4.1.4.
So here's our POJO:
And our configuration class:
So there's no @introspected here (@SerdeImport is meta-annotation but doesn't contain it) however Jakarta Validation works which was confirmed by our tests.
Steps To Reproduce
No response
Environment Information
No response
Example Application
No response
Version
4.1.4
The text was updated successfully, but these errors were encountered: