go-playground/validator

Struct and field validation library for Go using struct tags. The standard validation library used by Gin, Echo, and Fiber web frameworks. Supports 100+ built-in validators (required, min, max, email, url, uuid, oneof, etc.) plus cross-field and cross-struct validation. Custom validators with RegisterValidation().

Evaluated Mar 06, 2026 (0d ago) vv10
Homepage ↗ Repo ↗ Developer Tools go validation struct tags api forms input-validation binding
⚙ Agent Friendliness
67
/ 100
Can an agent use this?
🔒 Security
95
/ 100
Is it safe for agents?
⚡ Reliability
86
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
85
Error Messages
78
Auth Simplicity
100
Rate Limits
100

🔒 Security

TLS Enforcement
100
Auth Strength
100
Scope Granularity
100
Dep. Hygiene
88
Secret Handling
85

Input validation library — proper use prevents invalid data. Validation alone is not a security boundary; combine with proper sanitization.

⚡ Reliability

Uptime/SLA
90
Version Stability
85
Breaking Changes
80
Error Recovery
88
AF Security Reliability

Best When

Validating Go API request structs in web frameworks (Gin, Echo, Fiber) with tag-based rules.

Avoid When

You need JSON schema generation, dynamic validation rules, or OpenAPI integration — use separate schema tools.

Use Cases

  • Validate HTTP API request body structs in Go web frameworks (Gin, Echo, Fiber) with struct tag annotations
  • Implement cross-field validation rules: validate two related fields consistently in a struct
  • Add custom business rule validators via RegisterValidation for domain-specific constraints
  • Validate configuration structs at startup to catch invalid settings before serving requests
  • Localize validation error messages for multi-language API responses

Not For

  • Runtime type validation — validator uses struct tags defined at compile time; for dynamic schemas use jsonschema
  • Pydantic-style schema generation — validator doesn't generate OpenAPI schemas; combine with swaggo for docs
  • Non-struct validation of arbitrary data — validator is struct-centric

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

Library — no auth needed.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

MIT licensed open source library.

Agent Metadata

Pagination
none
Idempotent
Full
Retry Guidance
Not documented

Known Gotchas

  • ValidationErrors must be cast from error — use err.(validator.ValidationErrors) to access individual field errors; plain Error() returns a combined message
  • Pointer fields need 'omitempty' to skip nil validation — without omitempty, a nil pointer for a required field passes validation
  • Custom validators receive fl FieldLevel interface — access the field value with fl.Field() and the struct with fl.Parent()
  • Cross-field validators use 'eqfield' tag (e.g., validate:'eqfield=Password') — test with the exact Go field name, not JSON tag name
  • go-playground/validator v10 changed some tag names from v9 — code migrated from v9 may silently skip validation if tags were removed/renamed
  • Slice/map validation requires 'dive' tag: validate:'required,dive,required' validates the slice itself and each element — without dive, element validation is skipped

Alternatives

Full Evaluation Report

Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for go-playground/validator.

$99

Scores are editorial opinions as of 2026-03-06.

5208
Packages Evaluated
26151
Need Evaluation
173
Need Re-evaluation
Community Powered