def is_email(self): """Checks if the data provided is a valid email format.""" default_message = '{} is not a valid email address'.format( self.display_name) if self.data and not CommonValidator.is_email(self.data): self.validation_error_builder.add_error(self, default_message, self.allow_multiple) return self
def test_is_email_true_when_email_valid(self): result = CommonValidator.is_email(VALID_EMAIL) self.assertTrue(result)
def test_is_email_false_when_email_invalid(self): result = CommonValidator.is_email(INVALID_EMAIL) self.assertFalse(result)