Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Go
  3. govalidator

govalidator

MITGov11.0.1

A Go package providing validators and sanitizers for strings, numerics, slices, and structs.

Visit WebsiteGitHubGitHub
6.2k stars573 forks0 contributors

What is govalidator?

Govalidator is a Go library that provides a comprehensive set of validators and sanitizers for strings, numbers, slices, and structs. It solves the problem of ensuring data correctness and security in Go applications by offering built-in validation for common formats (like emails, URLs, IPs) and extensible custom validation rules.

Target Audience

Go developers building web services, APIs, or any backend application that requires robust input validation and data sanitization.

Value Proposition

Developers choose Govalidator for its extensive built-in validators, easy struct and map validation via tags, and flexibility to add custom rules, making it a one-stop solution for data validation in Go projects.

Overview

[Go] Package of validators and sanitizers for strings, numerics, slices and structs

Use Cases

Best For

  • Validating user input in Go web applications and APIs
  • Ensuring struct fields meet specific format requirements (e.g., email, URL)
  • Sanitizing strings by removing unwanted characters or normalizing data
  • Validating nested map structures in configuration or request data
  • Adding custom validation logic for domain-specific business rules
  • Checking data types and formats before database operations

Not Ideal For

  • Projects requiring compile-time validation errors instead of runtime checks
  • High-performance systems where validation overhead must be minimized
  • Teams using Go frameworks with built-in validation bindings (e.g., Gin's binding)
  • Applications needing validation schemas defined in JSON/YAML for cross-language use

Pros & Cons

Pros

Extensive Built-in Validators

Includes validators for emails, URLs, IPs, UUIDs, credit cards, and many common formats, reducing the need for custom code.

Declarative Struct Validation

Uses struct tags to define validation rules, making it easy to annotate fields with requirements like 'required' or 'email'.

Custom Validation Extensibility

Supports adding custom validators with parameterized tags and context-aware functions for domain-specific logic.

String Sanitization Utilities

Provides functions like WhiteList and BlackList for cleaning strings, plus trimming and normalization operations.

Cons

Incomplete Validator Coverage

The README's TODO list admits missing validators like IsFQDN and IsIMEI, requiring custom work for some formats.

Breaking Changes and API Instability

Recent updates changed custom validator signatures and registration methods, causing migration issues for existing code.

Runtime Validation Overhead

Relies on reflection and runtime tag evaluation, which can impact performance and lacks compile-time safety.

Frequently Asked Questions

Quick Stats

Stars6,211
Forks573
Contributors0
Open Issues108
Last commit1 day ago
CreatedSince 2014

Tags

#sanitization#api#validation#validation-library#go-library#input-validation#data-integrity#backend#govalidator#go#struct-validation

Built With

G
Go

Links & Resources

Website

Included in

Go169.1k
Auto-fetched 17 hours ago

Related Projects

validatorvalidator

:100:Go Struct and Field validation, including Cross Field, Cross Struct, Map, Slice and Array diving

Stars20,088
Forks1,444
Last commit4 days ago
ozzo-validationozzo-validation

An idiomatic Go (golang) validation package. Supports configurable and extensible validation rules (validators) using normal language constructs instead of error-prone struct tags.

Stars4,118
Forks244
Last commit2 years ago
govalidatorgovalidator

Validate Golang request data with simple rules. Highly inspired by Laravel's request validation.

Stars1,344
Forks122
Last commit2 years ago
ZogZog

Go with Zod inspired simple schema validation

Stars1,201
Forks40
Last commit12 days ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub