def test_should_throw_error_on_invalid_value(self): constraint = RegexConstraint(reg="^[A-Za-z0-9]+$") with self.assertRaises(RegexMismatchException): constraint.validate("Hello 1")
def test_should_validate_values_within_regex(self): constraint = RegexConstraint(reg="^[A-Za-z0-9]+$") self.assertEqual("Hello1", constraint.validate("Hello1"))