Skip to content

Combined Matchers - AND (implemented) or OR (to be implemented) #249

Open

Description

@orj

I have a question regarding matchers specified via the Pact FFI IntegrationJSON format.

Is there a way of combining matchers? From what I understand matchers can be combined in terms of "AND" and "OR" semantics. So it would be cool to specify say a bit of a response or request was both "a string" and also must be not empty. Eg, an "AND" combine of the "type" and "notEmpty" matchers.

Can this be done via the "Integration JSON" method?

Activity

  1. changed the title [-]Question: Combine Matchers with Integration JSON[/-] [+]Question: Can you combine Matchers with Integration JSON?[/+] on Jan 16, 2023
  2. rholshausen commented on Jan 30, 2023

    @rholshausen
    Contributor

    Unfortunately, the Pact FFI Integration JSON format only allows specifying a single matcher. However, as part of the plugins work we developed a matching rule expression language, which does allow multiple matchers. We could update the JSON format to support the expressions.

  3. YOU54F commented on Jun 9, 2024

    @YOU54F
    Member

    Does #405 resolve this at least for the AND case

  4. changed the title [-]Question: Can you combine Matchers with Integration JSON?[/-] [+]Combined Matchers - AND (implemented) or OR (to be implemented)[/+] on Oct 21, 2025
  5. YOU54F commented on Oct 21, 2025

    @YOU54F
    Member

    Combined matcher AND is now included in the pact-core and available in some consuming library DSL's.

    I will look to document examples of implementations, and feature support.

    We should look to support the OR combined matcher, to be compliant with the spec, and the pact-jvm implementation.

    It will help address some of the biggest faq questions, where our principles stand in the way of user need/want.

    Whilst I understand it is another foot gun for the user, it unblocks a route to adoption, and get helps get the pact core in rust, and pact-jvm at parity.

  6. sergewar commented on Jan 21, 2026

    @sergewar

    @YOU54F what do you think about using oneOf instead of or?
    #399 (comment)

  7. mefellows commented on Jan 21, 2026

    @mefellows
    Member

    How does oneOf fix this issue? If only one of the oneOfs are tested, aren't you in the same place as or?

  8. sergewar commented on Oct 20, 2026

    @sergewar

    Do you mind if I try to add support OR rule with Claude assistance?

  9. sergewar commented on Nov 2, 2026

    @sergewar

    Added pull request #599

  10. YOU54F commented on Nov 9, 2026

    @YOU54F
    Member

    Do you mind if I try to add support OR rule with Claude assistance?

    Not opposed to AI contributions. I just want to to know that the contributor understands the changes and have done an appropriate level of testing themselves. What client language(s) dsl's are you looking to consume it in? and what language services to you have to interop with?

    That will help us work out which wrappers to review, and a path to help you test them out locally if not already.

  11. sergewar commented on Nov 10, 2026

    @sergewar

    What client language(s) dsl's are you looking to consume it in? and what language services to you have to interop with?
    Now I'm using TS/JS https://github.com/pact-foundation/pact-js and Scala https://github.com/jbwheatley/pact4s
    Mostly using for checking messages, not http requests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions