Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date Comparison within Range in === Operator #38

Open
luizgustavodarossi opened this issue Jul 22, 2024 · 0 comments · May be fixed by #39
Open

Date Comparison within Range in === Operator #38

luizgustavodarossi opened this issue Jul 22, 2024 · 0 comments · May be fixed by #39

Comments

@luizgustavodarossi
Copy link

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 "==="

'===' => ->(v, d) { v[0] == v[1] },

 '==='   => ->(v, d) { v[0] === v[1] }, 
@luizgustavodarossi luizgustavodarossi linked a pull request Jul 23, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant