title: How to validate an integer using hibernate validator using GWT Editor framework
body: <p>I am using hibernate validator together with the Editor framework to validate inputs against DTO's in my GWT project.</p>
  
  <p>The problem I have is that the user is inputing a string in a text box, which should be validated as an integer. I have tried to apply the hibernate-validator annotations to automatically get it working but it seems I am missing something.</p>
  
  <p>My DTO:</p>
  
  <pre><code>public class MyDto {  
     @Min(value = 1, message = "Radius must be at least 1 meter.")
     private int radius = 100;
  
     ...
  }
  </code></pre>
  
  <p>I am using a GWT IntegerBox to read the value for the radius, and this works correctly when entering a value such as -1, but not when I enter a value that is not an integer, "hi" for example.</p>
  
  <p>The only way I have found to validate this is to issue a getValueOrThrow() on the IntegerBox and then manually set the error. Is there no way to express this using hibernate-validator annotations directly?</p>
  
  <p>I have tried using Integer and @NotNull, @NotEmpty, @Valid.</p>
  
  <p>My current code looks something like this:</p>
  
  <pre><code>try {
      radiusBox.getValueOrThrow();
  }
  catch (final ParseException e) {
      radiusDecorator.setErrorText("Invalid radius value.");
      return;
  }
  
  final MyDto dto = editorDriver.flush();
  final Set&lt;ConstraintViolation&lt;?&gt;&gt; violations = clientValidator.validate(dto);
  
  if (!violations.isEmpty()) {
      editorDriver.setConstraintViolations(violations)
      return;
  }
  </code></pre>