Exemple #1
0
 def to_python(self, value):
     """Verifies that the value is a string with a valid CIDR IP address"""
     if value and not is_valid_cidr(value) and not is_valid_ip(value):
         raise exceptions.ValidationError(
             "Value must be a valid CIDR address")
     else:
         return value
Exemple #2
0
 def to_python(self, value):
     """Verifies that the value is a string with a valid CIDR IP address"""
     if value:
         if isinstance(value, six.binary_type):
             value = six.text_type(value, encoding='utf-8')
         if not is_valid_cidr(value) and not is_valid_ip(value):
             raise exceptions.ValidationError("Value must be a valid CIDR address")
     return value
Exemple #3
0
def validate_cidr(value):
    """Validator for cidr xxx.xxx.xxx.xxx/xx"""
    if not value or not is_valid_cidr(value):
        raise forms.ValidationError('Must be a valid CIDR address!')
Exemple #4
0
 def clean(self, value):
     if value and not is_valid_cidr(value):
         raise forms.ValidationError("Value must be a valid CIDR address")
     else:
         return super(CIDRField, self).clean(value)
Exemple #5
0
 def clean(self, value):
     if value and not is_valid_cidr(value):
         raise forms.ValidationError(
             "Value must be a valid CIDR address")
     else:
         return super(CIDRField, self).clean(value)
Exemple #6
0
def validate_cidr(value):
    """Validator for cidr xxx.xxx.xxx.xxx/xx"""
    if not value or not is_valid_cidr(value):
        raise forms.ValidationError(
            'Must be a valid CIDR address!')