title: Spring validation: How do I remove leading/trailing whitespace from an email before validation?
body: <p>I’m using Spring 3.2.11.RELEASE.  I have a form mapped to a model that contains this field …</p>
  
  <pre><code>import org.hibernate.validator.constraints.Email;
  import org.hibernate.validator.constraints.NotEmpty;
  …
  
  public class RegistrationForm extends PasswordForm
  {
  
      @Email
      @NotEmpty
      private String email;
  </code></pre>
  
  <p>Then in my controller I have …</p>
  
  <pre><code>@RequestMapping(value = "/save", method = RequestMethod.POST)
  public ModelAndView register(final Model model,
                               final HttpServletRequest request,
                               final HttpServletResponse response,
                               @Valid final RegistrationForm registrationForm,
                               final BindingResult result) throws IOException
  </code></pre>
  
  <p>However, if the email comes in with leading or trailing whitespace, the validation fails.  Is there a way to adjust my annotation or do something else simple that will allow my validation to pass and have the leading/trailing whitespace removed from the email address?  I’m looking for a server-side solution, so although I realize I could make Javascript do the dirty work, I’d like to do that on the server side.</p>
  
  <p>Thanks, - Dave</p>