Skip to content

Commit

Permalink
validate replaced with field validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Lvyshnevska committed Oct 13, 2023
1 parent 0613517 commit cb27ec6
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions profiles/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,10 @@ class Meta:
class ProfileDeleteSerializer(serializers.Serializer):
password = serializers.CharField(write_only=True, required=True)

def validate(self, data):
password = data.get("password")
def validate_password(self, data):
user = self.context["request"].user
if not user.check_password(password):
raise serializers.ValidationError({"password": "Invalid password"})
if not user.check_password(data):
raise serializers.ValidationError("Invalid password")
return data


Expand Down

0 comments on commit cb27ec6

Please sign in to comment.