Skip to content

Conversation

mjnewman
Copy link

Hello! Very impressed by JSON Logic – It works exceptionally well. Great work!

I added a few operators for evaluating array conditions. These seem to be working well for my needs and I wanted to submit them as a pull request.

Hopefully these are helpful and, if so, can be incorporated. Thanks for your time and consideration!

@jwadhams
Copy link
Owner

Hey, sorry if you're getting weird cross notifications, I've never seen that happen between repos before.

This looks like good functionality to add with two caveats:

  1. Would it be possible for you to create some unit tests? If you run phpunit it'll download the shared tests from jsonlogic.com into tests/tests.json. You can append to the bottom. The basic format is that the whole file is an array. Comments are strings, and tests are an array of rule, data, expected outcome. I can use the unit tests to build the matching functionality in the JS library. In PHP every rule gets run twice, once with json_decode using PHP associative arrays, and once using PHP objects.
  2. I'm starting to think about having some light weight name spaces around functionality groups. The original idea came from this issue [Feature] Usage of custom function json-logic-js#3 but I think it would make the library easier to grok even for new "native" functionality. So something like renaming these functions array.compare and array.key_exists ? (That would suggest I should alias or rename the functions array.merge and array.in)

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 this pull request may close these issues.

2 participants