diff --git a/JsonLogic.Net.UnitTests/JsonLogicTests.cs b/JsonLogic.Net.UnitTests/JsonLogicTests.cs index 177257c..96c1d3c 100644 --- a/JsonLogic.Net.UnitTests/JsonLogicTests.cs +++ b/JsonLogic.Net.UnitTests/JsonLogicTests.cs @@ -89,8 +89,8 @@ public JsonLogicTests(ITestOutputHelper output) [InlineData("{`>`: [3, 4, 1]}", false)] [InlineData("{`>=`: [3, 2, 1]}", true)] [InlineData("{`>=`: [3, 1, 1]}", true)] - [InlineData("{`>=`: [3, 4, 1]}", false)] - + [InlineData("{`>=`: [3, 4, 1]}", false)] + [InlineData("{`<`: [`2020-01-31`, `2020-02-01`, `2020-02-02`]}", true)] [InlineData("{`<`: [`2020-01-31`, `2020-02-02`, `2020-02-02`]}", false)] [InlineData("{`<`: [`2020-01-31`, `2020-02-03`, `2020-02-02`]}", false)] @@ -148,6 +148,9 @@ public JsonLogicTests(ITestOutputHelper output) [InlineData("{`in`: [`Spring`, `Springfield`]}", true)] [InlineData("{`in`: [`Springs`, `Springfield`]}", false)] [InlineData("{`in`: [`spring`, `Springfield`]}", false)] + + [InlineData("{`in`:[`/homePage`,{`var`:`page.url`}]}", false)] + [InlineData("{`cat`: [`spring`, `field`]}", "springfield")] [InlineData("{`substr`: [`springfield`, 6]}", "field")] [InlineData("{`substr`: [`springfield`, 6, 3]}", "fie")] diff --git a/JsonLogic.Net/EvaluateOperators.cs b/JsonLogic.Net/EvaluateOperators.cs index 01ca0c4..5d2e494 100644 --- a/JsonLogic.Net/EvaluateOperators.cs +++ b/JsonLogic.Net/EvaluateOperators.cs @@ -227,6 +227,7 @@ private void AddDefaultOperations() AddOperator("in", (p, args, data) => { object needle = p.Apply(args[0], data); object haystack = p.Apply(args[1], data); + if (haystack is null) return false; if (haystack is String) return (haystack as string).IndexOf(needle.ToString()) >= 0; return haystack.MakeEnumerable().Any(item => item.EqualTo(needle));