示例#1
0
文件: models.py 项目: DerekRies/fjord
    def validate_url(self, attrs, source):
        value = attrs[source]
        if value:
            if not is_url(value):
                raise serializers.ValidationError(
                    '{0} is not a valid url'.format(value))

        return attrs
示例#2
0
 def __call__(self, value):
     # is_url turns around and uses URLValidator regex, so this
     # covers everything URLValidator covers plus some other
     # things.
     if not is_url(value):
         raise ValidationError(self.message, code=self.code)