https://linen.dev logo
#help
Title
# help
t

Tarun Bhalla

11/29/2023, 4:46 PM
Hey guys is it possible to match a stub with current date? For example I have { "request": { "method": "POST", "url": "/xyz/xyz", "bodyPatterns": [ { "matchesJsonPath": CURRENT DATE (also current date - 1 year or + 1 year) }] } Would matching the current date be possible in this case?
t

Tom

11/29/2023, 5:04 PM
Hi @Tarun Bhalla, yes you can do this using the the date matchers e.g.
Copy code
{
  "matchesJsonPath": {
    "expression": "$.completedDate",
    "after": "now +1 years",
    "truncateExpected": "first hour of day"
  }
}
t

Tarun Bhalla

11/29/2023, 5:08 PM
Perfect thanks Tom!
👍 1
Hey Tom just one more question with this, so hypothetically if i was to be matching to more that 1 value so... "matchesJsonPath": "$[?(@.abc == '123' && @.xyz == '456' && currentDate == '$.completedDate'. )]" would something like that be feasible or what I have to create separate matchesJsonPath blocks to filter my request?
t

Tom

11/29/2023, 9:06 PM
You’d need separate blocks or the logical AND matcher
t

Tarun Bhalla

11/29/2023, 9:24 PM
Would you have any examples of a block that might do something similar to this? Just for me to reference off of - just new to wiremock and trying to play around with values
9 Views