def check_value(self, value):
     try:
         int(value)
     except ValueError:
         raise ValidationError(
             "Value for Max Size validator must be 'integer', got '{0}'".
             format(type(value).__name__))
 def check_value(self, value):
     try:
         int(value)
     except ValueError:
         raise ValidationError(
             "Min Length value must be an 'integer', got '{0}'".format(
                 type(value).__name__))
 def register_validator(cls, key):
     try:
         ValidatorFactory.get_class(key)
     except KeyError:
         raise ValidationError(
             "Validator with key '{0}' does not exist".format(key))
     cls.allowed_validators.add(key)
    def validate_schema(cls, validator):
        errors = []
        expected_keys = list(cls.VALIDATOR_KEYS)
        for key in validator:
            try:
                expected_keys.remove(key)
            except ValueError:
                errors.append(
                    ("Key '{0}' either doesn't belong in the schema or"
                     " is duplicated").format(key))
                continue

        for key in expected_keys:
            errors.append(
                "Required key '{0}' missing from the schema".format(key))

        if errors:
            raise ValidationError(errors)
 def check_value(self, value):
     if not isinstance(value, list):
         raise ValidationError(
             "Value for File Types validator must be 'list', got '{0}'".
             format(type(value).__name__))
 def field_allows_validator(cls, field):
     if cls.VALIDATOR_KEY not in field.allowed_validators:
         raise ValidationError(
             ("Field '{0}' of type '{1}' does not accept the '{2}' "
              "validator type").format(field.id, field.type,
                                       cls.VALIDATOR_KEY))
 def check_value(self, value):
     if not isinstance('value', str):
         raise ValidationError(
             "Value for Contains validator must be 'string', got '{0}'".
             format(type(value).__name__))