package
Version:
v1.5.0
Opens a new window with list of versions in this module.
Published: Jun 22, 2026
License: MIT
Opens a new window with license information.
Imports: 9
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
¶
Package bind 提供 HTTP 请求参数绑定与校验能力,集成 validator 校验与中文翻译。
适用于 gin 框架,将 ShouldBindJSON 与 struct validate 合并为一步调用。
NewTrans 创建中文翻译器,注册默认翻译规则。
NewValidate 创建 validator 实例。
Binder 请求参数绑定器,组合 JSON 绑定与 struct 校验。
New 创建绑定器,需注入 validator、翻译器及业务错误码。
ShouldBindJSON 将请求体 JSON 绑定到 data 并执行 struct 校验,返回首条翻译后的校验错误。
ShouldBindJSONArray 将请求体 JSON 数组绑定到 data 并逐个校验元素。
data 必须是指向切片的指针,如 &[]SomeDto{} 或 &[]*SomeDto{}。
Source Files
¶
Click to show internal directories.
Click to hide internal directories.