I have validator validating, for instance, input data. It gets object product
(class Product
) created with default constructor
. One of Product fields is description
, and it has @NotNull
annotation.
When I run test it fails obviously and shows NullPointerException
. I can surround part of code where NullPointerException
was thrown with if-else like this
if(description!=null){
// product validation
}else{
errors.rejectValue("description", errorCode, defaultMessage);
}
That works, but i need something else, maybe using annotations.