https://github.com/budnieswski/validate-struct
Go package for Struct Validation - Validate the data coming from a JSON into a Struct, without having to decode it beforehand!
https://github.com/budnieswski/validate-struct
go golang golang-library golang-package struct-validator validate validation validation-library validator
Last synced: about 2 months ago
JSON representation
Go package for Struct Validation - Validate the data coming from a JSON into a Struct, without having to decode it beforehand!
- Host: GitHub
- URL: https://github.com/budnieswski/validate-struct
- Owner: budnieswski
- License: mit
- Created: 2022-04-13T14:07:50.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-04-29T20:28:52.000Z (almost 4 years ago)
- Last Synced: 2025-11-22T17:11:03.462Z (4 months ago)
- Topics: go, golang, golang-library, golang-package, struct-validator, validate, validation, validation-library, validator
- Language: Go
- Homepage:
- Size: 36.1 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Validate Struct
[](https://github.com/budnieswski/validate-struct/tags)
[](https://coveralls.io/github/budnieswski/validate-struct?branch=main)
[](https://goreportcard.com/report/github.com/budnieswski/validate-struct)
[](https://pkg.go.dev/github.com/budnieswski/validate-struct)
[](#)
[](#)
## Contents
- [Install](#install)
- [Example](#example)
- [Goals](#goals)
## Install
```
go get github.com/budnieswski/validate-struct
```
## Example
```golang
package main
import (
"encoding/json"
"fmt"
ValidateStruct "github.com/budnieswski/validate-struct"
)
type User struct {
ID uint64 `json:"id" validate:"required,min=2,max=4"`
Name string `json:"name" validate:"required,min=3"`
Status bool `json:"status"`
}
func main() {
input := []byte(`
{
"id": 12,
"name": "Mr Dummy",
"status": true
}
`)
valid := ValidateStruct.Validate(input, User{})
if len(valid) > 0 {
fmt.Println("Validation failed")
resp, _ := json.Marshal(valid)
fmt.Println(string(resp))
}
}
```
## Goals
- [ ] Create validate tests
- [ ] Create rule tests
- [ ] Standardize validate error return
- [ ] Create Github templates
- [ ] Contributing
- [ ] Issue
- [ ] Pull request
- [ ] Create Github workflows
- [X] Tests
- [X] Coverage
- [ ] CI
- [ ] Create doc.go
- [ ] Make validate benchmarks
- [ ] Improve performance
- [ ] Create a way for the user add custom rules