Repository navigation
Godantic v1.5.0 — Custom Tags, Plugins & Dynamic Fields
🚀 Godantic v1.5.0 — Custom Tags, Plugins & Dynamic Fields
We are proud to announce Godantic v1.5.0, a powerful and extensible validation engine for Go! This release marks a significant leap forward in flexibility, allowing developers to inject custom logic and support dynamic schemas like never before.
✨ Highlights
✅ Custom Validation Tags
You can now register your own validation rules with type-safe generic functions:
godantic.RegisterCustom[string]("starts_with_A", func(val string, path string) *godantic.Error {
if !strings.HasPrefix(val, "A") {
return &godantic.Error{ErrType: "STARTS_WITH_A_ERR", Path: path, Message: "Field must start with A"}
}
return nil
})Apply it using:
type User struct {
Name *string `json:"name" validate:"starts_with_A"`
}Supports multiple tags per field!
🔌 Plugin-Based Validation
Godantic now supports embedded logic with:
type ValidationPlugin interface {
Validate() *godantic.Error
}Any struct that implements Validate() will be automatically invoked during validation. Works for nested fields and lists!
🔄 Dynamic Field Validation
Support for polymorphic or runtime-defined fields with:
type DynamicFieldsValidator interface {
GetValue() any
GetValueType() string
GetAttribute() string
}Let your structs declare how they should be validated at runtime — ideal for schema-driven forms, rules, or input engines.
⚙️ Improvements
- Refactored validation flow for better performance and modularity.
- Supports pointers, nested fields, arrays, enums, regex, formats, and conditions (
when:). - Enhanced path resolution for more accurate error messages.
📚 Documentation
All docs are now available in the new docs/ folder, ready for GitHub Pages or your static site generator.
🏁 Getting Started
go get github.com/grahms/godanticThen explore docs/getting-started.md or the README for full examples.