-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Description
There's UnmarshalJSON and UnmarshalYAML for the unmarshalers, then there's SetDefaults for the https://github.com/creasty/defaults but for the validator, you need to use the RegisterValidation thing.
Could the validator just call some kind of Validate() error function on all targets if they have it?
type Config struct {
Attrs *Attributes
}
type Attributes struct {
Setting bool
Value valueString
}
type valueString string
func (v valueString) Validate() error {
if strings.HasPrefix(v, "x") {
return fmt.Errorf("can't start with x")
}
return nil
}
func (a Attributes) Validate() error {
if a.Setting {
return fmt.Errorf("this setting must be true")
}
return nil
}mvrahden, mrg0lden, cryptix and seanamos
Metadata
Metadata
Assignees
Labels
No labels