Exemplo n.º 1
0
    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
Exemplo n.º 2
0
    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
Exemplo n.º 3
0
 def test_check_non_validated_object(self):
     """Check if the value is not validated"""
     assert not utils.check_validation("*****@*****.**")
Exemplo n.º 4
0
 def test_check_validated_object(self):
     """Check if the value is validated"""
     self.assertTrue(utils.check_validation("*****@*****.**"))