Closed DFog14 closed 6 months ago
The function was never intended to take more than 2 logical.
You can see the code we have in 5.9.2 here and see that we have a check for properties.length !== 2
.
In other words, what currently happens in v5.x is the function does nothing if you specify more than 2 logicals.
We could possibly make it take more than 2 logicals tho. I'll keep that ticket around.
:tada: This issue has been resolved in version 1.19.0 :tada:
The release is available on @stoplight/spectral-rulesets-1.19.0
Your semantic-release bot :package::rocket:
Describe the bug In Spectral5.9.2, the core XOR function could accept more than 2 items in its properties' list. In Spectral6+, the core XOR function only appears to support two logical.
To Reproduce Create a ruleset that leverages the core XOR function:
each-component-property-must-contain-only-one: given: $.components...properties.* recommended: true severity: warn then: function: xor functionOptions: properties:
This rule running on 5.9.2 will work with no issue This rule running on 6+ will result in the following error: Error #1: "xor" and its "properties" option support 2-item tuples, i.e. ["id", "name"]
Expected behavior The XOR function will behave in the way that it always has, allowing more than just 2 logicals.
Additional context I understand that from an electrical perspective, an XOR gate only takes two inputs, but XOR functionality can support an unlimited number of inputs in practical use. If this was an intended behavior change, then so be it, it just seems like an odd decision to make as it breaks compatibility and the docs page still lists the function as supporting a list of logicals.
Judging by commit histories, it looks like the xor function was completely redesigned in 6.0.0alpha1, this redesign seems to have limited it to two logicals