An idiomatic Go validation package using normal programming constructs instead of struct tags.
ozzo-validation is an idiomatic Go validation library that provides configurable and extensible data validation capabilities. It solves the problem of validating user input and data structures using normal Go programming constructs instead of error-prone struct tags, making validation logic more explicit and maintainable.
Go developers building applications that require robust input validation, such as REST APIs, web services, or data processing pipelines.
Developers choose ozzo-validation for its clean, programmatic approach to validation, rich set of built-in rules, and flexibility to define custom validators without relying on opaque struct tags.
An idiomatic Go (golang) validation package. Supports configurable and extensible validation rules (validators) using normal language constructs instead of error-prone struct tags.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses standard Go code instead of error-prone struct tags, making validation logic explicit and easier to debug, as shown in the Address struct example where rules are defined as functions.
Includes a comprehensive suite of validators like Required, Length, Email, and URL out of the box, reducing the need for custom implementations for common cases.
Supports customizable error messages, error codes, and structured error output, such as JSON marshaling of validation errors using the json.Marshaler interface.
Allows rules to depend on runtime context via ValidateWithContext, enabling dynamic validation based on external factors like request parameters.
For basic validations, writing Go code can be more verbose compared to tag-based approaches, requiring more boilerplate for straightforward rules.
The library intentionally avoids struct tags, which might necessitate refactoring or additional work for projects migrating from tag-based systems or integrating with frameworks that expect them.
Creating custom rules requires implementing interfaces like validation.Rule, which can be less intuitive for developers new to the library or those accustomed to simpler validation methods.