Class HostnameValidator

  • All Implemented Interfaces:
    Serializable, FieldValidator

    public class HostnameValidator
    extends Object
    implements FieldValidator
    This validator class validates a string representing a host name.

    To be considered valid, the field value must be in one of these formats:

    • A domain name, like google.com
    • An IPv4 address string, like 127.0.0.1
    • An IPv6 address string with or without brackets, like [2001:db8::1] or 2001:db8::1
    • The string localhost
    Since:
    7.1
    See Also:
    Serialized Form
    • Constructor Detail

      • HostnameValidator

        public HostnameValidator()
    • Method Detail

      • validate

        public void validate​(Field field)
                      throws ValidationException
        Description copied from interface: FieldValidator
        Implementations of this method can perform any necessary validation on the Field. If the field is deemed invalid, a ValidationException should be thrown with a descriptive error message.
        Specified by:
        validate in interface FieldValidator
        Parameters:
        field - the field (name and value) to validate.
        Throws:
        ValidationException - if the field is invalid.