Skip to content

Commit 965569e

Browse files
authored
Merge pull request #392 from dirkbolte/doc-number-value-matchers
adding documentation for number matchers
2 parents 2e3d2ba + 1f385b3 commit 965569e

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

src/content/docs/docs/request-matching.mdx

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2005,3 +2005,51 @@ stubFor(
20052005
```
20062006
</TabItem>
20072007
</Tabs>
2008+
2009+
# Numbers
2010+
2011+
You can match numbers in their String representation using `equalTo`. For matching based on their numeric value, use `equalToNumber`, `greaterThanNumber`, `greaterThanEqualNumber`, `lessThanNumber` and `lessThanEqualNumber`.
2012+
2013+
The matchers always report inputs that cannot be parsed to a number as not matching. It can be used for matching both strings and numbers.
2014+
<Tabs>
2015+
<TabItem label="Java">
2016+
```java
2017+
stubFor(get(urlPathEqualTo("/things"))
2018+
.withQueryParam("id", greaterThanNumber(1))
2019+
.willReturn(ok()));
2020+
```
2021+
</TabItem>
2022+
<TabItem label="JSON">
2023+
```json
2024+
{
2025+
"request" : {
2026+
"urlPath" : "/things",
2027+
"method" : "GET",
2028+
"queryParameters" : {
2029+
"id" : {
2030+
"greaterThanNumber": "1"
2031+
}
2032+
}
2033+
},
2034+
"response" : {
2035+
"status" : 200
2036+
}
2037+
}
2038+
2039+
{
2040+
"request" : {
2041+
"urlPath" : "/things",
2042+
"method" : "GET",
2043+
"queryParameters" : {
2044+
"id" : {
2045+
"greaterThanNumber": 1
2046+
}
2047+
}
2048+
},
2049+
"response" : {
2050+
"status" : 200
2051+
}
2052+
}
2053+
```
2054+
</TabItem>
2055+
</Tabs>

0 commit comments

Comments
 (0)