json-logic-ruby
json-logic-ruby copied to clipboard
Date Comparison within Range in === Operator
I have a problem when trying to compare dates within a range using the === operator. The current implementation does not support this.
range = Date.parse('2024-01-01')..Date.parse('2024-12-31')
date = Date.parse('2024-07-22')
rule = {
"===" => [
{ "var" => "range" },
{ "var" => "date" }
]
}
data = {
"date" => date,
"range" => range
}
result = JSONLogic.apply(rule, data)
# expected result is true, but in all cases it returns false
We could add the command "===" https://github.com/bhgames/json-logic-ruby/blob/1fe6722b3de6f29cab5beaa86146953cf60b388b/lib/json_logic/operation.rb#L88
'===' => ->(v, d) { v[0] === v[1] },