| 1072 | } |
| 1073 | |
| 1074 | func 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 | |
| 1103 | func mergeSchema(left, right schema) schema { |
| 1104 | if left.Kind == schemaUnknown { |