def validate(cls, value):
        ip_utils = IpAddrUtils()
        if ip_utils.is_valid_ip(value) is False:
            raise ValueError(
                'Invalid IP address format: expected IPv4 or IPv6 address. provided: {}'
                .format(value))

        return value
示例#2
0
 def test_ipv6_regex_validation(self):
     ip_utils = IpAddrUtils()
     for ip_addr in IPv6_ADDRESSES:
         self.assertTrue(ip_utils.is_valid_ip(ip_addr))