func ValidateEvent()

in events/validators.go [70:96]


func ValidateEvent(name string, it EventType, ot EventType, got []byte) *ValidationInfo {
	want := OutputData(name, ot, it != ot)

	// If validating CloudEvent to CloudEvent (no event conversions),
	// the output data should be exactly the same as the input data.
	if it == CloudEvent && ot == CloudEvent {
		want = InputData(name, it)
	}

	if want == nil {
		// Include the possibilities in the error.
		return &ValidationInfo{
			Name:          name,
			SkippedReason: fmt.Sprintf("no expected output value of type %s", ot),
		}
	}

	switch ot {
	case LegacyEvent:
		return validateLegacyEvent(name, got, want)
	case CloudEvent:
		return validateCloudEvent(name, got, want)
	}

	// Should be unreachable.
	return nil
}