From db57572a546fceb070b5fc0b84a4bf819c8cbae9 Mon Sep 17 00:00:00 2001 From: Gani Georgiev Date: Mon, 11 Nov 2024 16:18:24 +0200 Subject: [PATCH] lowered the max field id and name length limit to 100 --- CHANGELOG.md | 2 +- core/field.go | 4 ++-- core/field_test.go | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50c4fc8f..55868f38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ - Added default max limits for the expressions count and length of the search filter and sort params. _This is just an extra measure mostly for the case when the filter and sort parameters are resolved outside of the request context since the request size limits won't apply._ -- Other minor changes (better error in case of duplicated rate limit rule, fixed typos, updated Go deps, etc.). +- Other minor changes (better error in case of duplicated rate limit rule, fixed typos, changed field id and name length validator to max 100, updated Go deps, etc.). ## v0.23.0-rc12 diff --git a/core/field.go b/core/field.go index e4645d0b..72eaa74c 100644 --- a/core/field.go +++ b/core/field.go @@ -191,7 +191,7 @@ func DefaultFieldIdValidationRule(value any) error { rules := []validation.Rule{ validation.Required, - validation.Length(1, 255), + validation.Length(1, 100), } for _, r := range rules { @@ -217,7 +217,7 @@ func DefaultFieldNameValidationRule(value any) error { rules := []validation.Rule{ validation.Required, - validation.Length(1, 255), + validation.Length(1, 100), validation.Match(fieldNameRegex), validation.NotIn(excludeNames...), validation.By(checkForVia), diff --git a/core/field_test.go b/core/field_test.go index 28bc46ec..fba7089a 100644 --- a/core/field_test.go +++ b/core/field_test.go @@ -91,7 +91,7 @@ func testDefaultFieldIdValidation(t *testing.T, fieldType string) { "invalid length", func() core.Field { f := core.Fields[fieldType]() - f.SetId(strings.Repeat("a", 256)) + f.SetId(strings.Repeat("a", 101)) return f }, true, @@ -100,7 +100,7 @@ func testDefaultFieldIdValidation(t *testing.T, fieldType string) { "valid length", func() core.Field { f := core.Fields[fieldType]() - f.SetId(strings.Repeat("a", 255)) + f.SetId(strings.Repeat("a", 100)) return f }, false, @@ -142,7 +142,7 @@ func testDefaultFieldNameValidation(t *testing.T, fieldType string) { "invalid length", func() core.Field { f := core.Fields[fieldType]() - f.SetName(strings.Repeat("a", 256)) + f.SetName(strings.Repeat("a", 101)) return f }, true, @@ -151,7 +151,7 @@ func testDefaultFieldNameValidation(t *testing.T, fieldType string) { "valid length", func() core.Field { f := core.Fields[fieldType]() - f.SetName(strings.Repeat("a", 255)) + f.SetName(strings.Repeat("a", 100)) return f }, false,