title: Java Bean Validation for long type
body: <p>I can't find a way to validate when a long variable comes with null value. I have to validate BigDecimal and long variables, for BigDecimal my custom annotation works fine, but for long type doesn't work. I'm using the Number class to wrap the incomming type and validate the value.</p>
  <pre><code>@Target(ElementType.FIELD)
  @Retention(RetentionPolicy.RUNTIME)
  @Constraint(validatedBy = NotNullNumberValidator.class)
  @Documented
  public @interface NotNullNumber {
  
      String message() default &quot;&quot;;
  
      Class&lt;?&gt;[] groups() default {};
  
      Class&lt;? extends Payload&gt;[] payload() default {};
  
  }
  </code></pre>
  <p>My <code>NotNullNumberValidator</code> class</p>
  <pre><code>class NotNullNumberValidator implements ConstraintValidator&lt;NotNullNumber, Number&gt; {
  
      @Override
      public boolean isValid(Number value, ConstraintValidatorContext context) {
          return value != null;
      }
  }
  </code></pre>
  <p>Use of the Anootation</p>
  <pre><code>@NotNullNumber(message = &quot;message for BigDecimal validation&quot;)
  private BigDecimal subtotal; //works fine
  
  @NotNullNumber(message = &quot;message for long validation&quot;)
  private long fechaPago;// not working}
  </code></pre>
  <p>Am I in the rigth way or there is another way to do this? <code>@NotNull</code> annotation doesn't make the job.</p>
  <p><strong>EDIT:</strong> I am using this validation with a @RequestBody, I want to validate if the JSON field (long) fechaPago is present in the request body.
  I know that with the wrapper class Long works, but I can't change the variable type (the rules are the rules here).</p>