Beispiel #1
0
    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
Beispiel #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)