title: URL validator for JEE6 Beans Validation 1.0
body: <p>How can I create a custom validator for a URL field in Beans Validation 1.0.
  But how can I pass the URL string passed via JSON into my constraint validator?</p>
  
  <pre><code>@ValidURL
  private URL myUrl;
  </code></pre>
  
  <hr>
  
  <pre><code>public class URLValidator implements ConstraintValidator&lt;ValidURL, CharSequence&gt; {...}
  </code></pre>
  
  <hr>
  
  <pre><code>@Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER})
  @Retention(RUNTIME)
  @Constraint(validatedBy = {URLValidator.class})
  @Constraint(validatedBy = {})
  public @interface ValidURL {
  
      String message() default "must be a valid URL";
  
      Class&lt;?&gt;[] groups() default {};
  
      Class&lt;? extends Payload&gt;[] payload() default {};
  }
  </code></pre>
  
  <p>I know the latest Hibernate Validator has a @URL validation but I cannot move to the latest version.</p>
  
  <p><strong>Edit:</strong>
  With the above I am hitting the following. So my question is how does Hibernate convert the URL type to the CharSequence used by the ConstraintValidator?</p>
  
  <pre><code>javax.validation.UnexpectedTypeException: HV000030: No validator could be found for type: java.net.URL.
  </code></pre>