I have a Spring rest webservice. The controller class map the parameters in the HTTP request to a custoom Request Object. My Request object looks like this:
public class DMSRequest_global {
protected String userName = "";
protected String includeInactiveUsers = "";
protected String documentType = ""; And the getter and setter of the fields above
}
Spring uses reflection to set the values from the incomming request to this object.My question is is it possible for us using annotation or some thing to validate a field like documentType in the example above to only accept a value from a list of acceptable values like {".doc", ".txt",".pdf"} . If some other value is sent in the request spring will throw an invalid request exception.