diff --git a/staging/src/k8s.io/apimachinery/pkg/api/validate/strfmt.go b/staging/src/k8s.io/apimachinery/pkg/api/validate/strfmt.go index d7524bbc666..190fa8dbe94 100644 --- a/staging/src/k8s.io/apimachinery/pkg/api/validate/strfmt.go +++ b/staging/src/k8s.io/apimachinery/pkg/api/validate/strfmt.go @@ -23,7 +23,6 @@ import ( "k8s.io/apimachinery/pkg/api/operation" "k8s.io/apimachinery/pkg/api/validate/content" - "k8s.io/apimachinery/pkg/api/validation/path" "k8s.io/apimachinery/pkg/util/validation/field" ) @@ -145,7 +144,7 @@ func PathSegmentName[T ~string](_ context.Context, op operation.Operation, fldPa return nil } var allErrs field.ErrorList - for _, msg := range path.IsValidPathSegmentName((string)(*value)) { + for _, msg := range content.IsPathSegmentName((string)(*value)) { allErrs = append(allErrs, field.Invalid(fldPath, *value, msg).WithOrigin("format=k8s-path-segment-name")) } return allErrs diff --git a/staging/src/k8s.io/apimachinery/pkg/api/validate/strfmt_test.go b/staging/src/k8s.io/apimachinery/pkg/api/validate/strfmt_test.go index d9e952a3e80..f2e84ffdbec 100644 --- a/staging/src/k8s.io/apimachinery/pkg/api/validate/strfmt_test.go +++ b/staging/src/k8s.io/apimachinery/pkg/api/validate/strfmt_test.go @@ -416,6 +416,9 @@ func TestPathSegmentName(t *testing.T) { ctx := context.Background() fldPath := field.NewPath("test") + // This format validator does not check for empty strings or max length, + // only checks path-segment-unsafe characters. Those constraints are + // handled by separate validators (Required, maxLength) in the schema. testCases := []struct { name string input string