Skip to content

Date Comparison within Range in === Operator #38

@luizgustavodarossi

Description

@luizgustavodarossi

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] }, 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions