Fail graciously when AP representation includes a null_value for mediaType
This commit is contained in:
parent
410d5f1d28
commit
c29a96f244
|
@ -708,23 +708,7 @@ class AudioSerializer(serializers.Serializer):
|
||||||
except (KeyError, TypeError):
|
except (KeyError, TypeError):
|
||||||
raise serializers.ValidationError('Missing mediaType')
|
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 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/'):
|
|
||||||
raise serializers.ValidationError('Invalid mediaType')
|
raise serializers.ValidationError('Invalid mediaType')
|
||||||
|
|
||||||
return v
|
return v
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Fail graciously when AP representation includes a null_value for mediaType
|
Loading…
Reference in New Issue