MCPcopy
hub / github.com/carvel-dev/ytt / CheckType

Method CheckType

pkg/schema/check.go:140–155  ·  view source on GitHub ↗

CheckType checks the type of `node` against this MapItemType. If `node` is not a yamlmeta.MapItem, `chk` contains a violation describing this mismatch If this map item's value is a scalar, checks its type against this MapItemType.ValueType

(node yamlmeta.Node)

Source from the content-addressed store, hash-verified

138// If `node` is not a yamlmeta.MapItem, `chk` contains a violation describing this mismatch
139// If this map item's value is a scalar, checks its type against this MapItemType.ValueType
140func (t *MapItemType) CheckType(node yamlmeta.Node) TypeCheck {
141 chk := TypeCheck{}
142 mapItem, ok := node.(*yamlmeta.MapItem)
143 if !ok {
144 chk.Violations = append(chk.Violations, NewMismatchedTypeAssertionError(node, t))
145 return chk
146 }
147
148 if _, isNode := mapItem.Value.(yamlmeta.Node); !isNode {
149 valChk := t.ValueType.CheckType(mapItem) // ScalarType checks mapItem.Value
150 if valChk.HasViolations() {
151 chk.Violations = append(chk.Violations, valChk.Violations...)
152 }
153 }
154 return chk
155}
156
157// CheckType checks the type of `node` against this ArrayType
158//

Callers

nothing calls this directly

Calls 3

HasViolationsMethod · 0.80
CheckTypeMethod · 0.65

Tested by

no test coverage detected