Okay, so I’ve updated your view and validation method
def put(self, request):
...
password = request.data['password']
confirm_password = request.data['confirm_password']
message = validation_password(password, confirm_password)
if message:
return Response(message, status=status.HTTP_400_BAD_REQUEST)
# Other code that you want to execute after validation_password
def validation_password(password, confirm):
message = None
if len(password) == 0:
message = {
'password': 'Password cannot be empty'
}
return message
if password != confirm:
message = {
'confirm_password': 'Confirm password not match with the password you given'
}
return message
Try this it will work.