https://linen.dev logo
#general
Title
# general
d

Debraj Manna

07/18/2023, 7:06 PM
Can someone let me know how I can match a number between 1 to 12 via regular expression in
bodyPatterns
? My request pattern looks like below
Copy code
"request": {
        "url": "/stripe/v1/payment_methods",
        "method": "POST",
        "bodyPatterns": [
          {
            "matches": "type=card&card\\[cvc\\]=[0-9]{3}&card\\[number\\]=[1-9][0-9]{15}&card\\[exp_month\\]=[1-9]|1[0-2]&card\\[exp_year\\]=2[0-9][2-9][3-9]",
            "caseInsensitive": false
          }
        ]
      }
But
exp_month
is not matching and throwing the below error
Copy code
-----------------------------------------------------------------------------------------------------------------------
| Closest stub                                             | Request                                                  |
-----------------------------------------------------------------------------------------------------------------------
                                                           |
v1_payment_methods                                         |
                                                           |
POST                                                       | POST
/stripe/v1/payment_methods                                 | /stripe/v1/payment_methods
                                                           | 
                                                           |
type=card&card\[cvc\]=[0-9]{3}&card\[number\]=[1-9][0-9]{  | type=card&card[cvc]=890&card[number]=4242424242424242&car<<<<< Body does not match
15}&card\[exp_month\]=[1-9]|1[0-2]&card\[exp_year\]=2[0-9  | d[exp_month]=1&card[exp_year]=2043
][2-9][3-9]                                                |
                                                           |
-----------------------------------------------------------------------------------------------------------------------
This has been answered in https://stackoverflow.com/q/76718195/785523 ... I have to add grouping.
Copy code
card\\[exp_month\\]=([1-9]|1[0-2])