def clean_from_address(self): from_address = self.cleaned_data['from_address'] from_address = from_address.strip() if (not email_re.match(from_address) and not DOM_RE.match(from_address) and not IPV4_RE.match(from_address) and not IPV4_NET_OR_RANGE_RE.match(from_address) and not ipaddr_is_valid(from_address)): raise forms.ValidationError(_("Provide either a valid IPv4/IPv6, email," " Domain address, or IPv4/IPv6 network or range")) return from_address
def validate_host(value): if not ipaddr_is_valid(value) and not DOM_RE.match(value): raise ValidationError( _(u'%s is not a valid hostname or IPv4/IPv6 address') % value)