Reputation: 335
I have a bean called Car.java which has the following fields :
private String name;
private String company;
private Maruti maruti;
@NotNull
@NotEmpty
@Size(min=5)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@NotNull
@NotEmpty
@Size(min=6)
public Maruti getMaruti() {
return maruti;
}
public void setMaruti(Maruti maruti) {
this.maruti = maruti;
}
public String getCompany() {
return company;
}
public void setCompany(String company) {
this.company = company;
}
where Maruti.java is another bean which has following field :
private String car_name;
private String car_model;
@NotNull
@NotEmpty
@Size(min=6)
public String getCar_name() {
return car_name;
}
public void setCar_name(String car_name) {
this.car_name = car_name;
}
I have added some annotations for validations in both the beans and in my main class I am calling
Set<ConstraintViolation<Car>> violations = validator
.validate(exchange.getIn().getBody(Car.class));
to validate the fields. Now the fields in Car.java are getting validating perfectly, but the annotations in Maruti.java doesn't work. Can anyone tell me why ?
Upvotes: 0
Views: 62