func (obj *ValidationErrObject) SafeExternalError() string {
	var sb strings.Builder
	sb.WriteString(fmt.Sprintf("validation failed on field '%s' on condition '%s'", obj.Field, obj.Condition))
	if obj.Param != "" {
		sb.WriteString(fmt.Sprintf(" [ %s ]: got %s", obj.Param, obj.getActualValueString()))
	}
	return sb.String()
}
SafeExternalError converts the ValidationErrObject to a string that is readable and safe
to send externally. In this case, "safe" means that when the `ActualValue` field is cast
to a string, it is type-checked so that only certain types are passed to the user. We
don't want an upstream command accidentally setting a complex object in the request field
that could leak sensitive information to the user. To limit this, we only support sending
static `ActualValue` types: `string`, `int`, `[]string`, and `[]int`. Otherwise, we say that
the actual value is "invalid type".

Note: the test cases split on "," to parse out the different errors. Don't add commas to the
safe external error.
package requestutils
import (
	"fmt"
	"net/http"
	"strings"
	"github.com/porter-dev/porter/api/server/shared/apierrors"
	"github.com/go-playground/validator/v10"
)
type Validator interface {
	Validate(s interface{}) apierrors.RequestError
}
type DefaultValidator struct {
	v10 *validator.Validate
}
func NewDefaultValidator() Validator {
	v10 := validator.New()
	v10.SetTagName("form")
	return &DefaultValidator{v10}
}
func (v *DefaultValidator) Validate(s interface{}) apierrors.RequestError {
	err := v.v10.Struct(s)
	if err == nil {
		return nil
	}
	errs, ok := err.(validator.ValidationErrors)
	if !ok {
		return apierrors.NewErrInternal(fmt.Errorf("could not cast err to validator.ValidationErrors"))
	}
	errorStrs := make([]string, len(errs))
	for i, field := range errs {
		errObj := NewValidationErrObject(field)
		errorStrs[i] = errObj.SafeExternalError()
	}
	return NewErrFailedRequestValidation(strings.Join(errorStrs, ","))
}
func NewErrFailedRequestValidation(valError string) apierrors.RequestError {
	return apierrors.NewErrPassThroughToClient(fmt.Errorf(valError), http.StatusBadRequest)
}
type ValidationErrObject struct {
	Field string
	Condition string
	Param string
	ActualValue interface{}
}
func NewValidationErrObject(fieldErr validator.FieldError) *ValidationErrObject {
	return &ValidationErrObject{
		Field:       fieldErr.Field(),
		Condition:   fieldErr.ActualTag(),
		Param:       fieldErr.Param(),
		ActualValue: fieldErr.Value(),
	}
}