-
Notifications
You must be signed in to change notification settings - Fork 28
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
Recursive matching rules #74
Comments
One way to do it would be to use something like the {
"//elements.id": {
"match": "type"
}
} This might be something to address with the V4 RFC |
Any Idea how would you weigh such matcher? |
It would be weighted on the number of elements that match |
This may be difficult to implement, because the consumer DSLs build up the structure as they go. So while we can define matching rules that can be applied to a subset of the document, I am unsure how the DSLs can be built to accommodate this. Having a DSL that has similar to Pact has to deal with both matching a document as well as generating one. |
I'm removing this from the V4 spec for now, because it needs more thinking. |
Given the current specification, I don't see a way to deal with self-contained matching rules -- i.e. matching rules for an object which contains itself as an attribute --, where the depth of the recursion is unknown.
For instance,
A pseudo-definition for such data structure,
element: { id: string, elements: []element }
This could be solved by enabling nth-level path expressions, so one could specify the matching rules for any "elements" attribute (1). Another solution could be implementing named matching rules and being able to reference them, so that the first-level "elements" would just reference back to a general named matching rule (2).
(1)
(2)
The problem with (2) is it generates an infinite number of possible rules, so I'm not sure of it's compatibility with your rule-weighting algorithm.
I am not sure if this could be pactified via regexp capturing groups, but in any case, I don't think that's a sustainable option.
The text was updated successfully, but these errors were encountered: