https://github.com/miniscruff/vaddy
Experimental validation library
https://github.com/miniscruff/vaddy
go golang validation
Last synced: over 1 year ago
JSON representation
Experimental validation library
- Host: GitHub
- URL: https://github.com/miniscruff/vaddy
- Owner: miniscruff
- License: mit
- Created: 2024-12-24T23:32:26.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-08T08:49:34.000Z (over 1 year ago)
- Last Synced: 2025-02-08T09:32:13.139Z (over 1 year ago)
- Topics: go, golang, validation
- Language: Go
- Homepage:
- Size: 29.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Vaddy
[](https://pkg.go.dev/github.com/miniscruff/vaddy)
[](https://github.com/miniscruff/vaddy/releases)
[](https://github.com/miniscruff/vaddy/blob/main/LICENSE)
Validation library using type safe, developer friendly and extendible functions.
> [!WARNING]
> This library is strictly around validations, parsing or building is otherwise left
> up to you.
> Validations that would otherwise fail parsing, are not handled or expected to be supported.
## Support
Currently experimental, valdiations will be added, changed or removed.
New validations may be added with `Exp` prefixes indicating they are still experimental.
## Examples
* [User](./example_user_test.go)
```go
package main
import (
"fmt"
v "github.com/miniscruff/vaddy"
)
type User struct {
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
Age uint8 `json:"age"`
}
func main() {
user := &User{
FirstName: "Badger",
LastName: "Smith",
Age: 45,
}
err := v.Join(
v.AllOf(u.FirstName, "first_name", v.StrMin(2), v.StrMax(64)),
v.AllOf(u.LastName, "last_name", v.StrMin(2), v.StrMax(64)),
v.AllOf(u.Age, "age", v.OrderedGte(uint8(0)), v.OrderedLte(uint8(130))),
)
fmt.Printf("validating user:\n%v\n", err)
}
```
## Benchmarks
Coming soon
> [!NOTE]
> If you have a particularly large or complex validation requirement, please share.
## Need help?
Use the [discussions page](https://github.com/miniscruff/vaddy/discussions) for help requests and how-to questions.
Please open [GitHub issues](https://github.com/miniscruff/vaddy/issues) for bugs and feature requests.
File an issue before creating a pull request, unless it is something simple like a typo.
## Want to Contribute?
If you want to contribute through code or documentation, the [Contributing guide](CONTRIBUTING.md) is the place to start.
If you need additional help create an issue or post on discussions.