title: Consistent JSR-303 validation with optional properties in Spring controllers and Spring webflow?
body: <p>Let's say I have a Model Bean "Vendor" with the mandatory property "name" and an optional property "email".</p>
  
  <pre><code>class Vendor {
  
      @Email
      private String email;
  
      @NotNull
      private String name;
  
  }
  </code></pre>
  
  <p>@Email allows Null!</p>
  
  <p>I want to use hibernate-validation in my <code>@Controller</code> and in my flows as well. I have in both scenarios the problem that a posted form with an empty field for email binds with "" and not NULL.</p>
  
  <p><code>StringTrimmerEditor</code> seems to solve my problem by converting "" into NULL. For my <code>@Controller</code> I found <a href="https://jira.springsource.org/browse/SPR-7077" rel="nofollow">SPR-7077</a> which suggests implementing <code>StringTrimmerEditor</code> globally with <code>@ControllerAdvice</code>. But this doesn't work for my flows.</p>
  
  <p>How do I achieve that globally empty Strings ("") are converted into NULL for JSR-303 validation in spring webflow?</p>