Browse Source

first erro details replace message of error

EUGENIO SOUZA CARVALHO 4 years ago
parent
commit
01a2cf9608
1 changed files with 4 additions and 2 deletions
  1. 4 2
      common/models.go

+ 4 - 2
common/models.go

@@ -362,7 +362,9 @@ func RequestParams(args string, params map[string]*Parameter) func(ctx context.C
 			}
 			sourceValue = value
 
-			if param.Required && (value == "" || value == nil) {
+			emptyValue := (value == "" || value == nil)
+
+			if param.Required && emptyValue {
 				invalidArgument := errs.InvalidArgument()
 				invalidArgument.Message = fmt.Sprintf(
 					"ParamRequired: param '%s' in '%s'",
@@ -372,7 +374,7 @@ func RequestParams(args string, params map[string]*Parameter) func(ctx context.C
 				return nil, invalidArgument
 			}
 
-			if param.ConvertTo != "" {
+			if !emptyValue && param.ConvertTo != ""  {
 				if value, err = convertValueByType(param.ConvertTo, value); err != nil {
 					invalidArgument := errs.InvalidArgument()
 					invalidArgument.Message = fmt.Sprintf(