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

Add matchers.Format for matching common types #109

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chrislawlor
Copy link

@chrislawlor chrislawlor commented Aug 11, 2021

Adds the match common formats feature from pact-python:

from pact import Format
Format().integer  # Matches if the value is an integer
Format().ip_address  # Matches if the value is a ip address

can be used in place of other matchers:

from pact import Like, Format
Like({
    'id': Format().integer, # integer
    'lastUpdated': Format().timestamp, # timestamp
    'location': { # dictionary
        'host': Format().ip_address # ip address
    }
})

Supported formats:

matcher description
identifier Match an ID (e.g. 42)
integer Match all numbers that are integers (both ints and longs)
decimal Match all real numbers (floating point and decimal)
hexadecimal Match all hexadecimal encoded strings
date Match string containing basic ISO8601 dates (e.g. 2016-01-01)
timestamp Match a string containing an RFC3339 formatted timestapm (e.g. Mon, 31 Oct 2016 15:21:41 -0400)
time Match string containing times in ISO date format (e.g. T22:44:30.652Z)
ip_address Match string containing IP4 formatted address
ipv6_address Match string containing IP6 formatted address
uuid Match strings containing UUIDs

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.

1 participant