diff --git a/eppo_client/rules.py b/eppo_client/rules.py index bc7c969..0327651 100644 --- a/eppo_client/rules.py +++ b/eppo_client/rules.py @@ -49,11 +49,11 @@ def evaluate_condition( if subject_value is not None: if condition.operator == OperatorType.MATCHES: return isinstance(condition.value, str) and bool( - re.match(condition.value, str(subject_value)) + re.search(condition.value, str(subject_value)) ) if condition.operator == OperatorType.NOT_MATCHES: return isinstance(condition.value, str) and not bool( - re.match(condition.value, str(subject_value)) + re.search(condition.value, str(subject_value)) ) elif condition.operator == OperatorType.ONE_OF: return isinstance(condition.value, list) and str(subject_value).lower() in [ diff --git a/eppo_client/version.py b/eppo_client/version.py index 131942e..8d1c862 100644 --- a/eppo_client/version.py +++ b/eppo_client/version.py @@ -1 +1 @@ -__version__ = "3.0.2" +__version__ = "3.0.3" diff --git a/test/rules_test.py b/test/rules_test.py index 7741b48..049dbfc 100644 --- a/test/rules_test.py +++ b/test/rules_test.py @@ -143,6 +143,27 @@ def test_evaluate_condition_matches(): ) +def test_evaluate_condition_matches_partial(): + assert evaluate_condition( + Condition( + operator=OperatorType.MATCHES, value="@example\\.com", attribute="email" + ), + {"email": "alice@example.com"}, + ) + assert not evaluate_condition( + Condition( + operator=OperatorType.MATCHES, value="@example\\.com", attribute="email" + ), + {"email": "alice@sample.com"}, + ) + assert evaluate_condition( + Condition( + operator=OperatorType.MATCHES, value="@example\\.com", attribute="email" + ), + {"email": "bob@example.com"}, + ) + + def test_evaluate_condition_not_matches(): assert not evaluate_condition( Condition(