Fail graciously when AP representation includes a null_value for mediaType

This commit is contained in:
Eliot Berriot 2018-04-18 00:08:31 +02:00
parent 410d5f1d28
commit c29a96f244
No known key found for this signature in database
GPG Key ID: DD6965E2476E5C27
2 changed files with 2 additions and 17 deletions

View File

@ -708,23 +708,7 @@ class AudioSerializer(serializers.Serializer):
except (KeyError, TypeError):
raise serializers.ValidationError('Missing mediaType')
if not media_type.startswith('audio/'):
raise serializers.ValidationError('Invalid mediaType')
return url
def validate_url(self, v):
try:
url = v['href']
except (KeyError, TypeError):
raise serializers.ValidationError('Missing href')
try:
media_type = v['mediaType']
except (KeyError, TypeError):
raise serializers.ValidationError('Missing mediaType')
if not media_type.startswith('audio/'):
if not media_type or not media_type.startswith('audio/'):
raise serializers.ValidationError('Invalid mediaType')
return v

View File

@ -0,0 +1 @@
Fail graciously when AP representation includes a null_value for mediaType