From 0177cbae7507bae51bb31eba3268f4312c28e321 Mon Sep 17 00:00:00 2001 From: Xing Zhou Date: Thu, 22 Dec 2016 12:34:17 +0800 Subject: [PATCH] Improve error messages for ValidateObject method. Improved error messages for method #ValidateObject in pkg/api/validation/schema.go. --- pkg/api/validation/schema.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/api/validation/schema.go b/pkg/api/validation/schema.go index 0214ca18b10..635bc392795 100644 --- a/pkg/api/validation/schema.go +++ b/pkg/api/validation/schema.go @@ -281,7 +281,7 @@ func (s *SwaggerSchema) ValidateObject(obj interface{}, fieldName, typeName stri // handle required fields for _, requiredKey := range model.Required { if _, ok := fields[requiredKey]; !ok { - allErrs = append(allErrs, fmt.Errorf("field %s for %s: is required", requiredKey, typeName)) + allErrs = append(allErrs, fmt.Errorf("field %s%s for %s is required", fieldName, requiredKey, typeName)) } } for key, value := range fields { @@ -302,7 +302,7 @@ func (s *SwaggerSchema) ValidateObject(obj interface{}, fieldName, typeName stri continue } if details.Type == nil && details.Ref == nil { - allErrs = append(allErrs, fmt.Errorf("could not find the type of %s from object: %v", key, details)) + allErrs = append(allErrs, fmt.Errorf("could not find the type of %s%s from object %v", fieldName, key, details)) } var fieldType string if details.Type != nil { @@ -311,7 +311,7 @@ func (s *SwaggerSchema) ValidateObject(obj interface{}, fieldName, typeName stri fieldType = *details.Ref } if value == nil { - glog.V(2).Infof("Skipping nil field: %s", key) + glog.V(2).Infof("Skipping nil field: %s%s", fieldName, key) continue } errs := s.validateField(value, fieldName+key, fieldType, &details)