Skip to content

Commit

Permalink
Ensure that name is not empty on server side
Browse files Browse the repository at this point in the history
  • Loading branch information
derneuere committed Jun 26, 2023
1 parent f421893 commit 16ce656
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions api/serializers/person.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ def get_video(self, obj) -> str:

def create(self, validated_data):
name = validated_data.pop("name")
if len(name.strip()) == 0:
raise serializers.ValidationError("Name cannot be empty")
qs = Person.objects.filter(name=name)
if qs.count() > 0:
return qs[0]
Expand Down

0 comments on commit 16ce656

Please sign in to comment.