I am using hibernate validators to implement validations in my application. I have also used custom annotations and custom validators for business validation requirements. It is working fine and I am able to get the specific error messages as per the implementation. But, now i also want to return error code (something like given in below code snippet) along with error message for each of the validations to the method where validate method is called.
I have read the documentation for hibernate validations but couldn't find anything for this requirement. Can some one please help me to implement error codes in this scenario.
@ValidStateInCountry(code=006, message="Invalid state for given country")
@ValidZipInCountry(code=007, message="Invalid zip for given country")
public class Address {
@NotBlank(code=001, message="address line is mandatory")
private String addressLine;
@ValidCountry(code=002, message="Invalid Country name")
@NotBlank(code=003, message="Country name is mandatory")
private String country;
@NotBlank(code=004, message="state is mandatory")
private String state;
@NotBlank(code=005, message="zip is mandatory")
private String zipCode;
}