Skip to content

Commit

Permalink
update readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
fumeboy committed Mar 11, 2021
1 parent a9f560c commit 554de19
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions schema/readme.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
通过嵌入匿名结构体的方式来实现类型传参
通过嵌入匿名结构体的方式来实现动态类型


期望

```go
type view struct {
FieldName inject.PathParam(IsPhoneNumber)
FieldName inject.PathParam(IsPhoneNumber, IsNULL)
}
```

不能接受的方案

```go
type view struct {
FieldName inject.PathParam `valid:"IsPhoneNumber"`
FieldName inject.PathParam `valid:"IsPhoneNumber, IsNULL"`
}
```

Expand All @@ -24,10 +24,13 @@ type view struct {
FieldName struct {
inject.PathParam
schema.IsPhoneNumber
schema.IsNULL
}
}
```

其中 schema.IsPhoneNumber 是空结构体

其中 Field 可以缩写成 `FieldName struct { inject.PathParam; schema.IsPhoneNumber }`
其中 Field 可以缩写成

`FieldName struct { inject.PathParam; schema.IsPhoneNumber; schema.IsNULL }`

0 comments on commit 554de19

Please sign in to comment.