Created
March 4, 2024 00:45
-
-
Save whiler/4f436195d39a08ac5ab2ad75887f57ee to your computer and use it in GitHub Desktop.
golang validator simple usage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "github.com/go-playground/validator/v10" | |
type Base struct { | |
Name string `yaml:"name" validate:"required"` | |
} | |
type Ext struct { | |
ID int `yaml:"id" validate:"gte=1,lt=10"` | |
} | |
type The struct { | |
Ext *Ext `yaml:",inline"` | |
Base *Base `yaml:"base"` | |
Children []*Base `yaml:"children" validate:"unique=Name,dive"` | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment