From 6f5b8af72515423329eb4321ee661e0a13675967 Mon Sep 17 00:00:00 2001 From: shiywang Date: Sat, 21 Jan 2017 00:12:15 +0800 Subject: [PATCH] fix validation errors in cli are cryptic typo --- 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 bb5ade46338..0214ca18b10 100644 --- a/pkg/api/validation/schema.go +++ b/pkg/api/validation/schema.go @@ -253,7 +253,7 @@ func (s *SwaggerSchema) ValidateObject(obj interface{}, fieldName, typeName stri if !ok && s.delegate != nil { fields, mapOk := obj.(map[string]interface{}) if !mapOk { - return append(allErrs, fmt.Errorf("field %s: expected object of type map[string]interface{}, but the actual type is %T", fieldName, obj)) + return append(allErrs, fmt.Errorf("field %s for %s: expected object of type map[string]interface{}, but the actual type is %T", fieldName, typeName, obj)) } if delegated, err := s.delegateIfDifferentApiVersion(&unstructured.Unstructured{Object: fields}); delegated { if err != nil { @@ -273,7 +273,7 @@ func (s *SwaggerSchema) ValidateObject(obj interface{}, fieldName, typeName stri } fields, ok := obj.(map[string]interface{}) if !ok { - return append(allErrs, fmt.Errorf("field %s: expected object of type map[string]interface{}, but the actual type is %T", fieldName, obj)) + return append(allErrs, fmt.Errorf("field %s for %s: expected object of type map[string]interface{}, but the actual type is %T", fieldName, typeName, obj)) } if len(fieldName) > 0 { fieldName = fieldName + "." @@ -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: is required", requiredKey)) + allErrs = append(allErrs, fmt.Errorf("field %s for %s: is required", requiredKey, typeName)) } } for key, value := range fields {