docs: give more examples of the verify (#590)

Signed-off-by: Rick <1450685+LinuxSuRen@users.noreply.github.com>
This commit is contained in:
Rick 2025-01-06 15:21:34 +08:00 committed by GitHub
parent 87fe3ee61a
commit 73d71a3321
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 27 additions and 0 deletions

View File

@ -19,6 +19,20 @@ title = "测试用例验证"
## 数组值检查
### 检查数组中是否有元素的字段包含特定值
示例数据:
```json
{
"data": [{
"key": "Content-Type"
}]
}
```
校验配置:
```yaml
- name: popularHeaders
request:
@ -28,6 +42,19 @@ title = "测试用例验证"
- any(data.data, {.key == "Content-Type"})
```
### 检查数组中是否有元素的字段只包含特定值
校验配置:
```yaml
- name: popularHeaders
request:
api: /popularHeaders
expect:
verify:
- all(data.data, {.key == "Content-Type" or .key == "Target"})
```
[更多用法](https://expr-lang.org/docs/language-definition#any).
## 字符串判断