Example #1
0
 def clean(self):
     self.vat = self.vat.strip()
     self.city = self.city.strip()
     validators.all_valid({
         'vat': (validators.validate_vat, self.vat, self.country),
         'zipcode': (validators.validate_zipcode, self.zipcode, self.country)
     })
Example #2
0
 def clean(self):
     self.vat = self.vat.strip()
     self.city = self.city.strip()
     validators.all_valid({
         'vat': (validators.validate_vat, self.vat, self.country),
         'zipcode':
         (validators.validate_zipcode, self.zipcode, self.country)
     })
Example #3
0
 def clean(self):
     self.description = self.description.strip()
     if hasattr(self, 'content_type'):
         validators.all_valid({
             'content_type': (self.handler.validate_content_type, self),
             'match': (self.handler.validate_match, self),
             'metric': (self.handler.validate_metric, self),
             'order_description': (self.handler.validate_order_description, self),
         })
Example #4
0
 def clean(self):
     self.description = self.description.strip()
     if hasattr(self, 'content_type'):
         validators.all_valid({
             'content_type': (self.handler.validate_content_type, self),
             'match': (self.handler.validate_match, self),
             'metric': (self.handler.validate_metric, self),
             'order_description':
             (self.handler.validate_order_description, self),
         })
Example #5
0
 def validate_value(self, value):
     if value:
         validators.all_valid(value, self.validators)
     valid_types = list(self.types)
     if isinstance(self.default, (list, tuple)):
         valid_types.extend([list, tuple])
     valid_types.append(type(self.default))
     if not isinstance(value, tuple(valid_types)):
         raise ValidationError(
             "%s is not a valid type (%s)." % (type(value).__name__, ", ".join(t.__name__ for t in valid_types))
         )
Example #6
0
 def validate_value(self, value):
     if value:
         validators.all_valid(value, self.validators)
     valid_types = list(self.types)
     if self.choices:
         choices = self.choices
         if callable(choices):
             choices = choices()
         choices = [n for n,v in choices]
         values = value
         if not isinstance(values, (list, tuple)):
             values = [value]
         for cvalue in values:
             if cvalue not in choices:
                 raise ValidationError("'%s' not in '%s'" % (value, ', '.join(choices)))
     if isinstance(self.default, (list, tuple)):
         valid_types.extend([list, tuple])
     valid_types.append(type(self.default))
     if not isinstance(value, tuple(valid_types)):
         raise ValidationError("%s is not a valid type (%s)." %
             (type(value).__name__, ', '.join(t.__name__ for t in valid_types))
         )
Example #7
0
 def validate_value(self, value):
     if value:
         validators.all_valid(value, self.validators)
     valid_types = list(self.types)
     if self.choices:
         choices = self.choices
         if callable(choices):
             choices = choices()
         choices = [n for n, v in choices]
         values = value
         if not isinstance(values, (list, tuple)):
             values = [value]
         for cvalue in values:
             if cvalue not in choices:
                 raise ValidationError("'%s' not in '%s'" %
                                       (value, ', '.join(choices)))
     if isinstance(self.default, (list, tuple)):
         valid_types.extend([list, tuple])
     valid_types.append(type(self.default))
     if not isinstance(value, tuple(valid_types)):
         raise ValidationError(
             "%s is not a valid type (%s)." %
             (type(value).__name__, ', '.join(t.__name__
                                              for t in valid_types)))