I want to validate the JSON request which I am receiving from the client side.
I have tried using the annotations (@notnull, @length(min=1,max=8), etc., etc.) and it is working fine but the problem is that I am not able to get the fields and messages which will be getting invoked if they are invalid.
Although, I am getting an error message in my Console.
List of constraint violations:
[
ConstraintViolationImpl
{
interpolatedMessage=
'must be greater than or equal to 900000000',
propertyPath=phoneNumber,
rootBeanClass=class
com.org.infy.prime.RestWithJPA.CarrierFile,
messageTemplate=
'{javax.validation.constraints.Min.message}'
}
ConstraintViolationImpl
{
interpolatedMessage=
'length must be between 1 and 20',
propertyPath=accountID,
rootBeanClass=class
com.org.infy.prime.RestWithJPA.CarrierFile,
messageTemplate=
'{org.hibernate.validator.constraints.Length.message}'
}
]
Request if anyone can help me on this or atleast give me an alternative to validate the request in a more efficient manner.
PS: I don't want to validate it field by field.