jwadhams / json-logic

Build complex rules and serialize them to JSON
MIT License
116 stars 13 forks source link

Date and time handling #27

Open larsbuch opened 3 years ago

larsbuch commented 3 years ago

These business rules defined in json logic is missing one essential thing as far as I see it that is date time handling in rules. I would love to be able to expres business rules in a generic way for frontend and backend and documentation but date and time is a part of the core. ISO date and time is the only needed support as all languages have conversion support.

Is there a suggestion of how to handle that?

atulagrawal commented 3 years ago

+1 as I have also few use cases for date validation !!

RuairiSpain commented 1 year ago

This is an important feature for Open Feature and Flagd support

RuairiSpain commented 1 year ago

Actually this does work, but if you are looking for a date rule, the data payload needs to match the variable names you set in the rules. I so if you want a beta test rule for feature flags, just send in the current date for both start and end.

Rule: { "and" : [ {">=" : [ { "var" : "start" }, "2023-03-01" ] }, {"<=" : [ { "var" : "end" }, "2023-04-01" ] } ] }

Data: { "start" : "2023-03-01", "end" : "2023-03-01"}