def METHOD_NAME(value):
    try:
        ipaddress.ip_network(value)
    except ValueError:
        raise exceptions.ValidationError(
            _('Enter a valid IP4 or IP6 network.'), code='invalid'
        )