govalidator
A comprehensive Go package of string, numeric, and struct validators and sanitizers, modeled on validator.js.
Repository Health
Technical Analysis
govalidator is a dependency-free Go library that provides a large catalog of Is* validation functions (emails, URLs, UUIDs, credit cards, IP addresses, ISBNs, JSON, base64, semver, and dozens more), To* type-conversion helpers, and string sanitizers like BlackList, WhiteList, and NormalizeEmail. It is explicitly modeled on the popular JavaScript library validator.js, bringing the same breadth of individual validators to Go.
Beyond standalone functions, govalidator ships a reflection-based ValidateStruct/ValidateMap engine driven by valid:"..." struct tags, so entire structs (including nested structs, slices, and pointers) can be validated declaratively. Custom validators, parameterized validators, and type-specific validators can all be registered into shared maps, and both struct and map validation have async variants that report results over channels.
What You Get
- Dozens of ready-made string validators — IsEmail, IsURL, IsUUID (v3/v4/v5), IsCreditCard, IsIP/IsIPv4/IsIPv6, IsISBN10/13, IsJSON, IsBase64, IsSemver, IsULID, and many more
- A reflection-based ValidateStruct and ValidateMap engine driven by
valid:"..."struct tags, with automatic recursion into nested structs, slices, and pointers - A pluggable validator registry (TagMap, ParamTagMap, CustomTypeTagMap, InterfaceParamTagMap) for registering custom or parameterized validation rules
- String sanitizers — BlackList, WhiteList, NormalizeEmail, StripLow, and case/whitespace helpers
- Type conversion helpers — ToInt, ToFloat, ToString, ToJSON, ToBoolean — with explicit error returns
- Async validation via ValidateStructAsync and ValidateMapAsync, which report bool/error results over channels
- Collection helpers over
[]interface{}— Filter, Each, Count, Find, ConditionIterator — for validating or transforming slices - A typed error model (Error/Errors) that tracks the failing field name, path, and validator for nested validation failures
Common Use Cases
- Validating incoming API request payloads (emails, URLs, UUIDs, IPs) before they reach business logic
- Declaratively validating config or form structs using
valid:"..."tags instead of hand-written if-checks - Sanitizing untrusted user input (stripping disallowed characters, normalizing emails) before storage
- Building custom domain-specific validators and registering them alongside the built-in ones for reuse across a codebase
Under The Hood
Architecture
govalidator is a flat, single-package library (no internal subpackages) organized by concern across files: validator.go (the largest file, ~1,800 lines, holding both the individual Is* validators and the ValidateStruct/ValidateMap/ValidateArray reflection-based engine), types.go (validator function-type definitions and the concurrency-safe custom-validator registries backed by sync.RWMutex), patterns.go (regex constants), utils.go (sanitizers), numerics.go (numeric comparisons), arrays.go (slice iteration helpers), converter.go (type conversion), and error.go (the Error/Errors types implementing Go’s error interface with path tracking). ValidateStruct walks struct fields via reflect, parses valid tags into an ordered tagOptionsMap, and dispatches to whichever validator maps match, recursing automatically into nested structs, pointers, and slices. Because validation dispatch is centralized through these shared tag-parsing and registry data structures, changes to the tag-option format would ripple across every call site that uses ValidateStruct or ValidateMap.
Tech Stack
The module (github.com/asaskevich/govalidator/v12, targeting Go 1.13) has zero third-party runtime dependencies — everything is built on the standard library (reflect, regexp, sync, net/mail, net/url, strings, sort). It is a leaf utility package meant to be imported directly rather than a service or CLI; there is no database, web framework, or build tooling beyond the Go toolchain itself. The repository still carries legacy CI configuration for Travis CI, CircleCI, and Wercker, but there is no active GitHub Actions workflow.
Code Quality
Test coverage is extensive: validator_test.go alone runs to nearly 4,000 lines, with companion _test.go, _benchmark_test.go, and _example_test.go files for every domain file (arrays, converter, numerics, utils, validator), using only the standard testing package (no assertion library like testify). Error handling is explicit and typed — validation failures return an Errors slice of Error values carrying the field name, path, and failing validator rather than being swallowed — and naming is consistent throughout (Is* predicates, To* converters, Validate* engine functions). There is no linter configuration checked into the repo and no active CI workflow currently enforcing tests on new commits, which is a gap for an otherwise well-tested library.
What Makes It Unique govalidator’s differentiator is breadth rather than architectural novelty — it is explicitly a Go port of the popular JavaScript library validator.js, aiming to cover the same wide surface of individual format validators (emails, credit cards, ISBNs, IPs, UUID variants, ULIDs, semver, magnet URIs, and more) in one package. Its more distinctive design choice is combining that catalog with a declarative, struct-tag-driven validation engine that supports custom validator registration and channel-based async validation, giving it both a scripting-style function-call API and a schema-like declarative API in the same package.
Used by 7 apps in this directory
Apache Answer
Community
Open-source Q&A platform for communities, help centers, and knowledge bases with AI assistant and plugin extensibility
Authelia
Security · Authentication
OpenID Certified SSO and MFA portal for securing self-hosted web applications behind reverse proxies.
Convoy
Developer Tools · Devops
Convoy is an open-source, cloud-native webhooks gateway that ingests events over HTTP or straight from Kafka, SQS, Google Pub/Sub, and RabbitMQ, then reliably delivers them to subscriber endpoints with signed payloads, automatic retries, circuit breaking, and JavaScript-based transformations.
Notifuse
Marketing
Open-source, self-hosted alternative to Mailchimp, Brevo, and Klaviyo — send newsletters and transactional emails without per-email pricing or vendor lock-in.
tau
Devops
Open-source, Git-native platform-as-a-service for building, deploying, and scaling fullstack apps on your own infrastructure with no DevOps required.
TiDB
Databases · AI Development
AI-Native Distributed SQL Database for Agentic Workloads
Vikunja
Project Management
Self-hosted task management with natural-language quick-add, multiple views, and a fully documented REST API — your tasks, your infrastructure, zero lock-in.