https://github.com/hyperscale-stack/validator
The Hyperscale Validator library provides a set of commonly needed data validators. It also provides a simple validator chaining mechanism by which multiple validators may be applied to a single datum in a user-defined order.
https://github.com/hyperscale-stack/validator
golang golang-module golang-package input-validation input-validator input-validators validator validators
Last synced: 21 days ago
JSON representation
The Hyperscale Validator library provides a set of commonly needed data validators. It also provides a simple validator chaining mechanism by which multiple validators may be applied to a single datum in a user-defined order.
- Host: GitHub
- URL: https://github.com/hyperscale-stack/validator
- Owner: hyperscale-stack
- License: mit
- Created: 2021-10-20T22:01:05.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2025-09-01T07:30:48.000Z (5 months ago)
- Last Synced: 2025-09-01T09:55:06.186Z (5 months ago)
- Topics: golang, golang-module, golang-package, input-validation, input-validator, input-validators, validator, validators
- Language: Go
- Homepage:
- Size: 62.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
Hyperscale Validator [](https://github.com/hyperscale-stack/validator/releases/latest) [](https://godoc.org/github.com/hyperscale-stack/validator)
====================
[](https://goreportcard.com/report/github.com/hyperscale-stack/validator)
| Branch | Status | Coverage |
|---------|--------|----------|
| master | [](https://github.com/hyperscale-stack/validator/actions?query=workflow%3AGo) | [](https://coveralls.io/github/hyperscale-stack/validator?branch=master) |
The Hyperscale Validator library provides a set of commonly needed data validators. It also provides a simple validator chaining mechanism by which multiple validators may be applied to a single datum in a user-defined order.
## Example
Validate by `map[string]interface{}`
```go
package main
import (
"fmt"
"github.com/hyperscale-stack/validator"
)
func main() {
i := NewInputValidator(map[string][]Validator{
"email": {
NewEmailValidator(EmailTimeout(1 * time.Second)),
},
})
errs := i.ValidateMap(map[string]interface{}{
"email": "bad",
})
// return
// map[string][]error{
// "email": []error{...},
// }
}
```
Validate by `url.Values`
```go
package main
import (
"fmt"
"github.com/hyperscale-stack/validator"
)
func main() {
i := NewInputValidator(map[string][]Validator{
"email": {
NewEmailValidator(EmailTimeout(1 * time.Second)),
},
})
values := url.Values{}
values.Set("email", "bad")
errs := i.ValidateValues(values)
// return
// map[string][]error{
// "email": []error{...},
// }
}
```
## License
Hyperscale Validator is licensed under [the MIT license](LICENSE.md).