github.com/decred/dcrlnd@v0.7.6/lncfg/interface.go (about) 1 package lncfg 2 3 // Validator is a generic interface for validating sub configurations. 4 type Validator interface { 5 // Validate returns an error if a particular configuration is invalid or 6 // insane. 7 Validate() error 8 } 9 10 // Validate accepts a variadic list of Validators and checks that each one 11 // passes its Validate method. An error is returned from the first Validator 12 // that fails. 13 func Validate(validators ...Validator) error { 14 for _, validator := range validators { 15 if err := validator.Validate(); err != nil { 16 return err 17 } 18 } 19 20 return nil 21 }