MCPcopy Create free account
hub / github.com/astercloud/aster / checkRequiredFields

Function checkRequiredFields

pkg/structured/structured.go:105–122  ·  view source on GitHub ↗

checkRequiredFields 校验顶层字段是否存在。

(data any, required []string)

Source from the content-addressed store, hash-verified

103
104// checkRequiredFields 校验顶层字段是否存在。
105func checkRequiredFields(data any, required []string) []string {
106 if len(required) == 0 {
107 return nil
108 }
109
110 obj, ok := data.(map[string]any)
111 if !ok {
112 return required
113 }
114
115 var missing []string
116 for _, field := range required {
117 if _, ok := obj[field]; !ok {
118 missing = append(missing, field)
119 }
120 }
121 return missing
122}

Callers 2

ParseMethod · 0.85
ParseTypedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected