diff --git a/business_rules/operators.py b/business_rules/operators.py index d43e5b1f..f965bb1e 100644 --- a/business_rules/operators.py +++ b/business_rules/operators.py @@ -87,6 +87,10 @@ def ends_with(self, other_string): def contains(self, other_string): return other_string in self.value + @type_operator(FIELD_TEXT, label="Contains (case insensitive)") + def contains_case_insensitive(self, other_string): + return other_string.lower() in self.value.lower() + @type_operator(FIELD_TEXT) def matches_regex(self, regex): return re.search(regex, self.value) @@ -95,6 +99,10 @@ def matches_regex(self, regex): def non_empty(self): return bool(self.value) + @type_operator(FIELD_NO_INPUT) + def is_empty(self): + return self.value is None or self.value.strip() == "" + @export_type class NumericType(BaseType): @@ -119,6 +127,10 @@ def _assert_valid_value_and_cast(value): def equal_to(self, other_numeric): return abs(self.value - other_numeric) <= self.EPSILON + @type_operator(FIELD_NUMERIC) + def not_equal_to(self, other_numeric): + return abs(self.value - other_numeric) > self.EPSILON + @type_operator(FIELD_NUMERIC) def greater_than(self, other_numeric): return (self.value - other_numeric) > self.EPSILON