Class Ipv4AddressValidator

  • All Implemented Interfaces:
    javax.validation.ConstraintValidator<Ipv4Address,​String>

    public class Ipv4AddressValidator
    extends Object
    implements javax.validation.ConstraintValidator<Ipv4Address,​String>
    Validates that a string value is a valid IPV4 address.
    Implementation Note:
    The logic here was adapted from the Apache Commons Validator's InetAddressValidator, re-written in a (somewhat) functional style that (we think) is more understandable and more easily testable since individual checks have been extracted into helper methods.
    • Constructor Detail

      • Ipv4AddressValidator

        public Ipv4AddressValidator()
    • Method Detail

      • initialize

        public void initialize​(Ipv4Address constraintAnnotation)
        Specified by:
        initialize in interface javax.validation.ConstraintValidator<Ipv4Address,​String>
      • isValid

        public boolean isValid​(String value,
                               javax.validation.ConstraintValidatorContext context)
        Specified by:
        isValid in interface javax.validation.ConstraintValidator<Ipv4Address,​String>