Skip to content
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

Feat/composing matching rules #405

Merged
merged 4 commits into from Mar 20, 2024
Merged

Conversation

rholshausen
Copy link
Contributor

Implements #399

TLDR - This allows an array to be specified with the pact:matcher:type attribute to be able to have multiple matching rules.

For example, you could do something like (just making this up, may not be valid):

{
    "pact:matcher:type": [
        { "pact:matcher:type": "regex", "regex": "\\w{3}-\\d+" },
        { "pact:matcher:type": "include", "value": "XYZ" }
    ]
}

@rholshausen
Copy link
Contributor Author

rholshausen commented Mar 20, 2024

As I was in that space, I also added support for the matching rule definition expressions. So you can also do

{
    "pact:matcher:type": "eachKey(matching(regex, '\\w{3}-\\d+', 'AUK-155332')), eachValue(matching(type, ''))",
}

Just note that using references (matching($'Example')) will not work.

Copy link
Contributor

@JP-Ellis JP-Ellis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks all pretty sensible to me.

Should the compatibility suite also be updated to make sure downstream libraries consistently use these?

@rholshausen
Copy link
Contributor Author

Looks all pretty sensible to me.

Should the compatibility suite also be updated to make sure downstream libraries consistently use these?

This is more an implementation detail. The language implementations can choose to use this form or use the FFI functions directly. The compatibility suite should assert the behavior, regardless.

@mefellows
Copy link
Member

Looks all pretty sensible to me.
Should the compatibility suite also be updated to make sure downstream libraries consistently use these?

This is more an implementation detail. The language implementations can choose to use this form or use the FFI functions directly. The compatibility suite should assert the behavior, regardless.

Yeah it was more the point of being able to add multiple matchers to a single field.

Ditto expressions.

This looks good though!

@rholshausen rholshausen merged commit 1a85d22 into master Mar 20, 2024
30 checks passed
@rholshausen rholshausen deleted the feat/composing-matching-rules branch March 20, 2024 04:43
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.

None yet

3 participants