Exemplo n.º 1
0
 def validate(self, field, row={}):
     field = json.loads(str(field))
     if not field and not self.empty_ok:
         self.invalid_set.add(field)
         raise ValidationException()
     if len(field) != len(set(field)):
         self.invalid_set.add(field)
         raise ValidationException()
Exemplo n.º 2
0
 def validate(self, field, row={}):
     if not field and not self.empty_ok:
         self.invalid_set.add(field)
         raise ValidationException()
     field = field.split(self.separator)
     if len(field) != len(set(field)):
         self.invalid_set.add(field)
         raise ValidationException()
Exemplo n.º 3
0
 def validate(self, field, row={}):
     try:
         if field or not self.empty_ok:
             self.cast(field)
     except ValueError as e:
         self.invalid_set.add(field)
         raise ValidationException(e)
Exemplo n.º 4
0
    def validate(self, field, row={}):
        if self.unique_with and not self.unique_check:
            self._precheck_unique_with(row)

        key = tuple([field] + [row[k] for k in self.unique_with])
        if key not in self.unique_values:
            self.unique_values.add(key)
        else:
            self.duplicates.add(key)
            if self.unique_with:
                raise ValidationException(
                    "'{}' is already in the column (unique with: {})".format(
                        field, key[1:]))
            else:
                raise ValidationException(
                    "'{}' is already in the column".format(field))
Exemplo n.º 5
0
 def validate(self, field, row={}):
     if field == "" and self.empty_ok:
         return
     try:
         value = float(field)
         if not self.low <= value <= self.high:
             raise ValueError
     except ValueError:
         self.outside.add(field)
         raise ValidationException("'{}' is not in range {} to {}".format(
             field, self.low, self.high))
Exemplo n.º 6
0
 def validate(self, field, row={}):
     if not field == "":
         self.failed = True
         raise ValidationException("Row has not empty field in column")
Exemplo n.º 7
0
 def validate(self, field, row={}):
     if field != "":
         self.nonempty.add(field)
         raise ValidationException("'{}' is not an empty string".format(field))
Exemplo n.º 8
0
 def validate(self, field, row={}):
     if not self.regex.match(field) and (field or not self.empty_ok):
         self.failures.add(field)
         raise ValidationException(
             "'{}' does not match pattern /{}/".format(field, self.regex)
         )
Exemplo n.º 9
0
 def validate(self, field, row={}):
     if field not in self.options:
         self.invalid_set.add(field)
         raise ValidationException(
             "'{}' is not in {}".format(field, _stringify_set(self.options, 100))
         )
Exemplo n.º 10
0
 def validate(self, field, row={}):
     if field not in self.valid_set:
         self.invalid_set.add(field)
         raise ValidationException("'{}' is not in {}".format(
             field, self.valid_set))
Exemplo n.º 11
0
 def validate(self, field, row={}):
     if field == '':
         self.failed = True
         raise ValidationException("Row has emtpy field in column")
Exemplo n.º 12
0
 def validate(self, field, row={}):
     if not self.low <= float(field) <= self.high:
         self.outside.add(field)
         raise ValidationException("'{}' is not in range {} to {}".format(
             field, self.low, self.high))