Skip to content

Commit

Permalink
纠正 options 传参说明
Browse files Browse the repository at this point in the history
  • Loading branch information
kesonan committed Jun 19, 2024
1 parent 9f748fe commit 732b341
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions docs/tutorials/api/parameter.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ type Foo {

在 api 描述语言中,我们可以通过在 tag 中来声明参数接收规则,除此之外,还支持参数的校验,参数校验的规则仅对 **请求体** 有效,参数校验的规则写在 tag value中,目前 go-zero 支持的参数校验规则如下:

| <img width={100}/>接收规则 | 说明 | 示例 |
| --- | --- |-------------------------------------|
| optional | 当前字段是可选参数,允许为零值(zero value) | \`json:"foo,optional"\` |
| options | 当前参数仅可接收的枚举值 | \`json:"gender,options=[foo,bar]"\` |
| default | 当前参数默认值 | \`json:"gender,default=male"\` |
| range | 当前参数数值有效范围,仅对数值有效,写法规则详情见下文温馨提示 | \`json:"age,range=[0:120]"\` |
| <img width={100}/>接收规则 | 说明 | 示例 |
|------------------------| --- |----------------------------|
| optional | 当前字段是可选参数,允许为零值(zero value) | \`json:"foo,optional"\` |
| options | 当前参数仅可接收的枚举值 | \`json:"gender,options=foo\|bar"\` |
| default | 当前参数默认值 | \`json:"gender,default=male"\` |
| range | 当前参数数值有效范围,仅对数值有效,写法规则详情见下文温馨提示 | \`json:"age,range=[0:120]"\` |

:::note range 表达式值规则

Expand Down

0 comments on commit 732b341

Please sign in to comment.