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

Method CheckType

pkg/schema/check.go:78–93  ·  view source on GitHub ↗

CheckType checks the type of `node` against this DocumentType. If `node` is not a yamlmeta.Document, `chk` contains a violation describing this mismatch If this document's value is a scalar, checks its type against this DocumentType.ValueType

(node yamlmeta.Node)

Source from the content-addressed store, hash-verified

76// If `node` is not a yamlmeta.Document, `chk` contains a violation describing this mismatch
77// If this document's value is a scalar, checks its type against this DocumentType.ValueType
78func (t *DocumentType) CheckType(node yamlmeta.Node) TypeCheck {
79 chk := TypeCheck{}
80 doc, ok := node.(*yamlmeta.Document)
81 if !ok {
82 chk.Violations = append(chk.Violations, NewMismatchedTypeAssertionError(node, t))
83 return chk
84 }
85
86 if _, isNode := doc.Value.(yamlmeta.Node); !isNode {
87 valChk := t.ValueType.CheckType(doc) // ScalarType checks doc.Value
88 if valChk.HasViolations() {
89 chk.Violations = append(chk.Violations, valChk.Violations...)
90 }
91 }
92 return chk
93}
94
95// CheckType checks the type of `node` against this MapType.
96//

Callers

nothing calls this directly

Calls 3

HasViolationsMethod · 0.80
CheckTypeMethod · 0.65

Tested by

no test coverage detected