登录 注册
其他
20,229
Stars
—
Forks
0
Watchers
—
Open Issues
待补全
许可证
Go
语言
—
创建时间
最近更新

项目能做什么

Go 结构体与字段校验库,支持跨字段、跨结构体以及 Map、Slice 的深度校验。
来源:AI 基于仓库事实生成 · 内容以仓库实际 README 为准

使用说明 查看原始 README 原仓库文档

中文使用说明暂未生成。下面保留原仓库 README 摘录,命令与配置均以原文为准。
原始 README 摘录(英文原文,节选前 3000 字符)
Package validator
=================
<img align="right" src="logo.png">[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/go-playground/validator)](https://github.com/go-playground/validator/releases)
[![Build Status](https://github.com/go-playground/validator/actions/workflows/workflow.yml/badge.svg)](https://github.com/go-playground/validator/actions)
[![Coverage Status](https://coveralls.io/repos/go-playground/validator/badge.svg?branch=master&service=github)](https://coveralls.io/github/go-playground/validator?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/go-playground/validator)](https://goreportcard.com/report/github.com/go-playground/validator)
[![GoDoc](https://godoc.org/github.com/go-playground/validator?status.svg)](https://pkg.go.dev/github.com/go-playground/validator/v10)
![License](https://img.shields.io/dub/l/vibe-d.svg)

Package validator implements value validations for structs and individual fields based on tags.

It has the following **unique** features:

-   Cross Field and Cross Struct validations by using validation tags or custom validators.
-   Slice, Array and Map diving, which allows any or all levels of a multidimensional field to be validated.
-   Ability to dive into both map keys and values for validation
-   Handles type interface by determining it's underlying type prior to validation.
-   Handles custom field types such as sql driver [Valuer](https://golang.org/src/database/sql/driver/types.go?s=1210:1293#L29) and the [Valuer interface](https://github.com/go-playground/validator/blob/master/_examples/valuer/main.go)
-   Alias validation tags, which allows for mapping of several validations to a single tag for easier defining of validations on structs
-   Extraction of custom defined Field Name e.g. can specify to extract the JSON name while validating and have it available in the resulting FieldError
-   Customizable i18n aware error messages.
-   Default validator for the [gin](https://github.com/gin-gonic/gin) web framework; upgrading from v8 to v9 in gin see [here](https://github.com/go-playground/validator/tree/master/_examples/gin-upgrading-overriding)

A Call for Maintainers
----------------------

Please read the discussion started [here](https://github.com/go-playground/validator/discussions/1330) if you are interested in contributing/helping maintain this package.

Installation
------------

Use go get.

	go get github.com/go-playground/validator/v10

Then import the validator package into your own code.

	import "github.com/go-playground/validator/v10"

Error Return Value
-------

Validation functions return type error

They return type error to avoid the issue discussed in the following, where err is always != nil:

* http://stackoverflow.com/a/29138676/3158232
* https://github.com/go-playground/validator/issues/134

Validator returns only InvalidValidationError for bad validation input, nil or ValidationErrors as type error; so, in your code all you n
阅读完整原文

项目深度分析 AI 生成

基于规则的可视化业务校验与配置管理平台 (SaaS/On-Premise)

产品构想将代码级的 tag 校验抽象为动态可配置的业务规则引擎,提供 Web 界面让业务人员或测试定义校验逻辑,并通过 gRPC/REST 服务或 Go SDK 动态加载执行,替代硬编码的 struct tag。
核心功能动态规则热更新、可视化规则编排器、多语言校验 SDK(以 Go validator 为底层引擎)、审计日志与告警、复杂依赖校验支持。
目标用户中大型互联网公司风控团队、电商业务开发、金融合规开发团队。
难度/周期高 · 6-12 个月 · 成本:中等(主要是全栈开发人力、云服务托管与文档建设)
收费模式按规则调用量收费的 SaaS 订阅,或按实例/集群收费的企业私有化部署授权。
竞争风险开发量大,重度依赖业务场景;与现有低代码平台或风控规则引擎存在竞争。
依据 AI推测

API 契约驱动的代码生成与校验套件 (Developer Tooling)

产品构想开发针对 OpenAPI/Swagger 和 Protobuf 的商业级代码生成工具,将 API 契约自动转换为带精准 go-playground/validator tag 的 Go 结构体及前端校验逻辑,实现前后端校验闭环。
核心功能OpenAPI/Protobuf 转 Go validator tags 代码生成器、前端表单校验代码同步导出、Breaking Change 静态分析与检测、CI/CD 插件。
目标用户中小型开发团队、微服务架构师、全栈工程师。
难度/周期中等 · 3-6 个月 · 成本:低(主要为 CLI 工具与文档开发,托管成本极低)
收费模式核心开源 + Pro 版付费(高级静态分析、企业级代码规范校验、团队共享规则模板授权)。
竞争风险市面上有开源生成插件(如 protoc-gen-validate),商业溢价空间较窄。
依据 尚需验证的假设

企业级技术支持、LTS 与安全合规审计服务

产品构想针对依赖该库的金融、医疗等强监管企业,提供官方/专家级的商业技术支持,解决社区目前面临的维护者精力不足问题(README 已挂出 Call for Maintainers),承诺 SLA、漏洞响应与自定义 tag 开发。
核心功能漏洞修复与 CVE 专属响应、定制化 validator 规则与插件开发、架构级性能优化咨询、长期支持维护(LTS)分支。
目标用户跨国银行、金融科技公司、医疗数据处理等对代码合规与供应链安全有硬性要求的企业。
难度/周期低 · 1-3 个月 · 成本:极低(主要是资深工程师的人工时间)
收费模式企业支持订阅年费(Support Contract)、定制咨询服务费。
竞争风险需要极高的行业声誉与公信力;个人独立开发者难以承担企业级 SLA 赔偿责任。
依据 已验证事实
AI 基于仓库公开数据分析生成,含推测成分,不构成收益承诺。
报告会保存到 个人中心

竞品与相似项目 GitHub Search 真实检索

相似项目数据正在完善中,暂不展示(避免误导)

项目优势与风险

技术成熟度创建时间待补全,最近推送 ,发布过 100 个 Release
社区活跃Star 20,229 / Fork 0 / Issue 0(数据支持,可自行核实)
许可证未检测到(需人工确认)
主要风险上游项目方向可能变化;同赛道竞争者较多(见竞品表);热度与需求不完全等价

安装与使用

此项目未提供 Docker 镜像,安装步骤以原仓库 README 为准(涉及依赖安装与环境配置,对新手门槛较高)。