// Validate returns an error if the report does not match its definition.
Validate returns an error if the report does not match its definition.
// Validate returns an error if the report does not match its definition .
func (mr MetricReport) Validate(def Definition) error {
	if mr.Name != def.Name {
		return fmt.Errorf("incorrect metric name: %v", mr.Name)
	}
	if mr.StartTime.After(mr.EndTime) {
		return fmt.Errorf("metric %v: StartTime > EndTime: %v > %v", mr.Name, mr.StartTime, mr.EndTime)
	}
	if err := mr.Value.Validate(def); err != nil {
		return fmt.Errorf("metric %v: %v", mr.Name, err)
	}
	return nil
}
func ( mr MetricReport ) Validate ( def Definition ) error { if mr . Name != def . Name { return fmt . Errorf ( " " , mr . Name ) } if mr . StartTime . After ( mr . EndTime ) { return fmt . Errorf ( " " , mr . Name , mr . StartTime , mr . EndTime ) } if err := mr . Value . Validate ( def ) ; err != nil { return fmt . Errorf ( " " , mr . Name , err ) } return nil }
Validate returns an error if the report does not match its definition.
Validate returns an error if the report does not match its definition .