-
Notifications
You must be signed in to change notification settings - Fork 492
Supporting optional jsonValueValidator in Operator class? #412
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
Comments
I want to chime in here as I'm facing a similar issue with my implementation. I noticed in testing that my 'notIn' checks are failing for empty values, when I think they should not be, as described here. My condition structure:
If the Edit: Digging in further the 'not' decorator gets around my issue with 'notIn'. In my case changing the operator to |
Following up again as I noticed another situation that's a bit difficult to get around given there's no fallback behavior in the decorators. Here's my secondary use case:
I'm wanting to validate that all the inputs are present in the test data. However, if the given pathway evaluates to an undefined value, then the initial 'sort' causes the issue and the whole test fails out since the error is not being handled internally. The resulting error stems from this line of code (as mentioned by OP):
I really think something like the proposed change here would be hugely beneficial. What would we need to get traction on a fix like this? |
@chris-pardy @CacheControl if I took a stab at a PR to implement the suggestion above is there a chance of this being accepted? |
Uh oh!
There was an error while loading. Please reload this page.
In the documentation on JSON rules engine operators it states that the fact passed to the contains/notContains operators must be arrays. And I see in the Operator class that a factValueValidator function can be supplied to the constructor to ensure that the fact supplied to this operator meets that expectation.
Similarly, the documentation states that for in/notIn operators, the value side of the comparison must be an array. But unlike contains/notContains, there's no validation in place to check that this is the case. And that means you don't have the same graceful handling when a non-array value is passed where an array is expected. A minimal-ish example to illustrate how in/notIn are not symmetrical to contains/notContains:
I'm curious if this is the intentional/desired behavior here? Naively I would've expected that in/notIn operators can (and would) validate values similarly to how contains/notContains validate facts. I think this could be accomplished with a minor rewrite to the Operator class, something like:
And tweaking the initialization of the default engine operators. If there's interest in doing something along these lines I'd be glad to try and throw together a small PR.
The text was updated successfully, but these errors were encountered: