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

Support combining matching rules #1203

Open
mefellows opened this issue Mar 27, 2024 · 3 comments
Open

Support combining matching rules #1203

mefellows opened this issue Mar 27, 2024 · 3 comments
Labels
enhancement Indicates new feature requests good first issue Indicates a good issue for first-time contributors help wanted Indicates that a maintainer wants help on an issue or pull request triage This issue is yet to be triaged by a maintainer

Comments

@mefellows
Copy link
Member

In some cases, you need to apply multiple matchers to a field in order to properly validate it. Only Pact JVM currently supports this behaviour.

The capability to combine matching rules will be enabled in the next release (v0.4.19), but the clients will need to update their DSLs to support it.

Motivating Use Case

From a request in slack.

How might you write a matcher to check both the keys and values and the same time (use eachKeyMatches and eachValueMatches simultaneously):

    enum Keys {
      One = "One",
      Two = "Two",
    }

    interface Value {
      min: number
      max: number
    }

    type R = Record<Keys, Value>
    const record: R  = {
      [Keys.One]:
        {
          min: 1,
          max: 2
        }
    }

  it("check record", async () => {
    messagePact
      .expectsToReceive("record")
      .withContent({
        // What need to write here to check type R ?
      })
  })

Proposed API to support this

TBC

Background: pact-foundation/pact-reference#399 (comment)

@mefellows mefellows added triage This issue is yet to be triaged by a maintainer enhancement Indicates new feature requests labels Mar 27, 2024
@mefellows mefellows added help wanted Indicates that a maintainer wants help on an issue or pull request good first issue Indicates a good issue for first-time contributors labels May 16, 2024
@mefellows
Copy link
Member Author

See also pact-foundation/pact-php#597

@sergewar
Copy link

@mefellows do you have any expectation when this feature will be implemented for JS?

@mefellows
Copy link
Member Author

There are no immediate plans to implement, so if you would like to pick this up I'd be happy to support you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Indicates new feature requests good first issue Indicates a good issue for first-time contributors help wanted Indicates that a maintainer wants help on an issue or pull request triage This issue is yet to be triaged by a maintainer
Projects
None yet
Development

No branches or pull requests

2 participants