MCPcopy Create free account
hub / github.com/AdRoll/baker / CheckRequiredFields

Function CheckRequiredFields

config.go:555–567  ·  view source on GitHub ↗

CheckRequiredFields checks that all fields that are tagged as required in cfg's type have actually been set to a value other than the field type zero value. If not CheckRequiredFields returns the name of the first required field that is not set, or, it returns an empty string if all required fields

(cfg interface{})

Source from the content-addressed store, hash-verified

553//
554// CheckRequiredFields doesn't support struct embedding other structs.
555func CheckRequiredFields(cfg interface{}) string {
556 fields := RequiredFields(cfg)
557
558 for _, name := range fields {
559 rv := reflect.ValueOf(cfg).Elem()
560 fv := rv.FieldByName(name)
561 if fv.IsZero() {
562 return name
563 }
564 }
565
566 return ""
567}
568
569// ErrorRequiredField describes the absence of a required field
570// in a component configuration.

Callers 2

TestCheckRequiredFieldsFunction · 0.92
decodeAndCheckConfigFunction · 0.85

Calls 1

RequiredFieldsFunction · 0.85

Tested by 1

TestCheckRequiredFieldsFunction · 0.74