Garmaine Staff asked 2 years ago

I’m new here and I have a problem with validation of my bean . I’m using Quarkus with MongoDB and when I try to run a create rest api, with @Valid before request bean, I expect an exception if I want to create a document with null field (obviously I use @NotNull in entity), but document is created without field. This is my code:


public class Car extends PanacheMongoEntityBase {

private long id;
private String carName;
@Size(min = 1, max = 3)
private String code;

// get and set





public class CarResource {

public List<Car> list() {
    return Car.listAll();

public Car get(long id) {
    return Car.findById(id);

public Response create(@Valid Car car) {
    return Response.status(201).build();

I have same problem with @Size annotation, because I can create a “code” field with more characters than 3.

And there an annotation like @Indexed(unique = true)? I want an unique field for my app.

Thank you in advice.