Legacy Documentation
You're viewing legacy documentation for API Fortress (deployed via an on-premises container).
To view documentation for the new SaaS version of API Fortress — now known as Sauce Labs API Testing and Monitoring (with Sauce Connect tunnels) — see
API Testing on the Sauce Labs Cloud.
This assertion is used to check if the element value described by the expression matches a knowledge base of some kind. For example a
US Zipcode or a
US State. This also gives you the ability to write your own regex (regular expression).
Parameters:
Name |
Type/Value |
Required |
Expression |
Expression |
Yes |
Type |
‘regex’ or ‘US Zipcode’ or ‘US State’ or ‘credit card’ or ‘country codes’ or ‘currency codes’ |
Yes |
Regex value |
String |
Yes, if type is ‘regex’ |
Mode |
‘all’ or ‘one’ |
No |
Level |
‘error’ or ‘warning’ |
No |
Modifier |
‘not’ |
No |
Execute if item exists |
‘true’ or ‘false’ |
No |
Stop test if fails |
‘true’ or ‘false’ |
No |
Comment |
String |
No |
Expression: It’s the path to the element we want to operate on (e
x: payload.ProductID). See
Expression for more details.
Type: The data type of the value. The possible values are: ‘regex’, if you want to evaluate the field as a regular expression (specified in regex value); ‘US Zipcode’, checks if the field is a valid US Zipcode; ‘US State’, checks if the field is a valid US State (i.e. ‘NY’); ‘credit card’; checks if the field contains a valid credit card number from the most popular credit cards (i.e. VISA, Mastercard, AMEX); ‘country codes’, checks if the field contains a valid country code (i.e. ‘US’, ‘FR’, ‘DK’); ‘currency codes’, checks if the fields is a valid currency (i.e. ‘USD’, ‘EUR’)
Regex value: Specify the regular expression you want to use for checking the expression.
Mode: Specify if all the same elements in the payload should match the assertion (‘all’) or if only one element (‘one’) is enough.
Level: Specify if the assertion fails whether it should be considered an ‘error’ or just a ‘warning.’ A warning will not trigger alerts (such as email or text messages).
Modifier: The assertion is considered verified if it does not pass.
Execute if item exists: The assertion is evaluated only if the element exists. This is useful when the element does not always exist.
Stop test if fails: The test will be immediately stopped if the assertion fails.
Code View Examples:
<assert-matches expression=”data.zipcode” type=”us_zipcodes”/> |
<assert-matches expression=”data.state” type=”us_states”/> |
<assert-matches expression=”data.name” type=”regex” value=”[hc]?at”/> |
<assert-matches expression=”data.credit” type=”creditCard”/> |
<assert-matches expression=”data.country” type=country_codes”/> |
<assert-matches expression=”data.code” type=”currency_codes”/> |