def validate_mobile(self, value: str) -> str: """ If pre-validated mobile number is required, this function checks if the mobile is pre-validated using OTP. Parameters ---------- value: str Returns ------- value: str """ if user_settings["MOBILE_VALIDATION"]: if check_validation(value=value): return value else: raise serializers.ValidationError("The mobile must be " "pre-validated via OTP.") else: return value
def validate_email(self, value: str) -> str: """ If pre-validated email is required, this function checks if the email is pre-validated using OTP. Parameters ---------- value: str Returns ------- value: str """ if user_settings["EMAIL_VALIDATION"]: if check_validation(value=value): return value else: raise serializers.ValidationError("The email must be " "pre-validated via OTP.") else: return value
def test_check_non_validated_object(self): """Check if the value is not validated""" assert not utils.check_validation("*****@*****.**")
def test_check_validated_object(self): """Check if the value is validated""" self.assertTrue(utils.check_validation("*****@*****.**"))