diff --git a/business_rules/operators.py b/business_rules/operators.py index d43e5b1f..55d982a9 100644 --- a/business_rules/operators.py +++ b/business_rules/operators.py @@ -95,6 +95,10 @@ def matches_regex(self, regex): def non_empty(self): return bool(self.value) + @type_operator(FIELD_TEXT) + def is_in(self, other_string): + return self.value in other_string + @export_type class NumericType(BaseType): diff --git a/tests/test_operators.py b/tests/test_operators.py index 824d4a69..0d51896c 100644 --- a/tests/test_operators.py +++ b/tests/test_operators.py @@ -46,6 +46,9 @@ def test_non_empty(self): self.assertFalse(StringType("").non_empty()) self.assertFalse(StringType(None).non_empty()) + def test_string_is_in(self): + self.assertTrue(StringType("hello").is_in("hello world")) + self.assertFalse(StringType("word").is_in("hello world")) class NumericOperatorTests(TestCase):