1
0
mirror of https://github.com/chai2010/advanced-go-programming-book.git synced 2025-05-24 04:22:22 +00:00

add validator

This commit is contained in:
Xargin 2018-01-09 14:40:33 +08:00
parent 9547de27d8
commit 72206694c8
2 changed files with 10 additions and 0 deletions

View File

@ -0,0 +1,10 @@
# 6.4. validator 请求校验
社区里曾经有人用这张图来嘲笑 PHP
![validate 流程](../images/validate.jpg)
实际上这是一个语言无关的场景需要进行字段校验的情况有很多web 系统的 Form/json 提交只是一个典型的例子。我们用 go 来写一个类似上图的校验 demo。然后研究怎么一步步对其进行改进。假设我们的数据已经通过某个 binding 库绑定到了具体的 struct 上。
```go
```

BIN
images/validate.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB