Esempio n. 1
0
    def validate(self, value, **kwargs):
        """
        Validate user input, which is presumed to be a string.

        Args:
            value (str): User input.
            account (AccountDB): The Account that is performing the validation.
                This is necessary because of other settings which may affect the
                check, such as an Account's timezone affecting how their datetime
                entries are processed.
        Returns:
            any (any): The results of the validation.
        Raises:
            ValidationError: If input value failed validation.

        """
        return validatorfuncs.text(value, option_key=self.key, **kwargs)
Esempio n. 2
0
 def test_text_raises_ValueError(self, mocked_str):
     mocked_str.side_effect = Exception
     with self.assertRaises(ValueError):
         validatorfuncs.text(None)
Esempio n. 3
0
 def test_text_ok(self):
     for val in [None, -123, "abc", 1.234, {1: True, 2: False}, ["a", 1]]:
         self.assertEqual(str(val), validatorfuncs.text(val))