MCPcopy
hub / github.com/superplanehq/superplane / validateExampleAgainstSpecs

Function validateExampleAgainstSpecs

pkg/lint/examplepayloads/checker.go:1074–1101  ·  view source on GitHub ↗
(example exampleRecord, specs []emitSpec)

Source from the content-addressed store, hash-verified

1072}
1073
1074func validateExampleAgainstSpecs(example exampleRecord, specs []emitSpec) []Issue {
1075 if len(specs) == 0 {
1076 return nil
1077 }
1078
1079 var payloadTypes []string
1080 typeMatched := false
1081 exampleType, _ := example.Payload["type"].(string)
1082 for _, spec := range specs {
1083 payloadTypes = append(payloadTypes, spec.PayloadType)
1084 if spec.PayloadType != exampleType {
1085 continue
1086 }
1087
1088 typeMatched = true
1089 break
1090 }
1091
1092 if !typeMatched {
1093 return []Issue{{
1094 Name: example.Name,
1095 Kind: example.Kind,
1096 Message: fmt.Sprintf("example payload type %q does not match any Emit(...) payload type: %s", exampleType, strings.Join(uniqueStrings(payloadTypes), ", ")),
1097 }}
1098 }
1099
1100 return nil
1101}
1102
1103func mergeSchema(left, right schema) schema {
1104 if left.Kind == schemaUnknown {

Callers 1

RunFunction · 0.85

Calls 1

uniqueStringsFunction · 0.85

Tested by

no test coverage detected