govalidator supplies validation and sanitization helpers for strings, numerics, slices, maps, and structs. Struct tags declare rules similar to validator.js patterns.
Overview
govalidator is a Go package of validators and sanitizers used widely in cloud-native projects. Functions cover URLs, emails, credit cards, and many string and numeric checks.
ValidateStruct reads struct tags to apply comma-separated rules per field, with options to require tags on all fields or allow nil pointers where configured. ValidateMap applies parallel rules to map values.
Custom validator callbacks can extend the library with context-aware checks, including dependencies between fields. The design is influenced by validator.js while idiomatic for Go types.
Downstream projects adopt it for configuration validation, API input checking, and shared sanitization pipelines.
Key features
- String and numeric checks
- Struct tag validation
- Map validation
- Custom validator callbacks
- Sanitizer helpers
- Optional required fields mode
- Collection iterators
Use cases
- API input validation
- Config struct checks
- Form data sanitization
- Shared validation rules