A lightweight struct validator for Go using struct tags and custom rules.
Gody is a lightweight struct validation library for Go that allows developers to validate data structures using struct tags and custom rules. It solves the problem of ensuring data integrity in Go applications, particularly for validating incoming HTTP request payloads, configuration structs, or any structured data. By leveraging Go's struct tags, it provides a declarative and type-safe way to enforce validation constraints.
Go developers building web APIs, microservices, or any application that requires robust input validation and data sanitization. It's especially useful for backend engineers who need to validate JSON request bodies, configuration files, or database models.
Developers choose Gody for its simplicity, performance, and seamless integration with Go's type system. Unlike heavier validation frameworks, it offers a minimal API, built-in common rules, and the flexibility to add custom rules, making it ideal for projects that need efficient and maintainable validation without unnecessary complexity.
:balloon: A lightweight struct validator for Go
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Gody enables validation rules to be defined directly in struct tags using a simple syntax like `validate:"not_empty"`, making code clean and maintainable, as shown in the HTTP handler example.
The library supports adding custom validation rules for specific business logic, and dynamic parameters allow avoiding duplication, demonstrated in the enum validation example with injected status values.
Gody prioritizes simplicity and performance with a minimal API that integrates seamlessly with Go's struct system, avoiding heavy dependencies, as stated in its philosophy and usage.
Offers various validation functions like Validate, RawValidate, and DefaultValidate, providing flexibility for different scenarios, detailed in the README section on 'Others ways for validation'.
Users must manually add rules using `validator.AddRules`, which can lead to boilerplate code and potential omissions, unlike libraries that auto-register validators based on tags.
While it includes common rules, Gody lacks built-in support for more complex validations like cross-field dependencies or regex patterns, which might require custom implementations and extra effort.
The contribution policy requires opening issues for discussion before any PR, which could slow down community contributions and feature development, as noted in the README.