Browse Source

fix: omit null value

Yeuoly 8 months ago
parent
commit
9cbd95abc4

+ 5 - 0
internal/types/entities/plugin_entities/basic_type.go

@@ -27,6 +27,11 @@ func isBasicType(fl validator.FieldLevel) bool {
 	switch fl.Field().Kind() {
 	case reflect.Int, reflect.String, reflect.Bool, reflect.Float64:
 		return true
+	case reflect.Ptr:
+		// check if the pointer is nil
+		if fl.Field().IsNil() {
+			return true
+		}
 	}
 
 	return false

+ 2 - 2
internal/types/entities/requests/tool.go

@@ -36,11 +36,11 @@ type RequestInvokeTool struct {
 
 type RequestValidateToolCredentials struct {
 	Provider    string         `json:"provider" validate:"required"`
-	Credentials map[string]any `json:"credentials" validate:"omitempty,dive,is_basic_type"`
+	Credentials map[string]any `json:"credentials" validate:"omitempty"`
 }
 
 type RequestGetToolRuntimeParameters struct {
 	Provider    string         `json:"provider" validate:"required"`
 	Tool        string         `json:"tool" validate:"required"`
-	Credentials map[string]any `json:"credentials" validate:"omitempty,dive,is_basic_type"`
+	Credentials map[string]any `json:"credentials" validate:"omitempty"`
 }