Annotation Interface HostOrIP


@Documented @Constraint(validatedBy={}) @Target({METHOD,FIELD,ANNOTATION_TYPE}) @Retention(RUNTIME) @Pattern(regexp="^((([\\p{Alnum}]([-\\p{Alnum}]*[\\p{Alnum}])?)\\.)+([\\p{Alpha}]([-\\p{Alnum}]*[\\p{Alnum}])?))|(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]))$") @ReportAsSingleViolation public @interface HostOrIP
Validation constraint requiring a String to be either a valid fully-qualified DNS hostname or an IPv4 address.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Class<?>[]
     
     
    Class<? extends jakarta.validation.Payload>[]
     
  • Element Details

    • message

      String message
      Default:
      "Not a valid hostname or IPv4 address"
    • groups

      Class<?>[] groups
      Default:
      {}
    • payload

      Class<? extends jakarta.validation.Payload>[] payload
      Default:
      {}