From 6c4850d967ee45d00c8b4fc583cfe93856973247 Mon Sep 17 00:00:00 2001 From: yutachaos <18604471+yutachaos@users.noreply.github.com> Date: Mon, 14 Oct 2024 19:11:33 +0900 Subject: [PATCH] Added test for StringLenBetween --- helper/validation/strings_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/helper/validation/strings_test.go b/helper/validation/strings_test.go index 9068c4f72f..1bb78630a0 100644 --- a/helper/validation/strings_test.go +++ b/helper/validation/strings_test.go @@ -243,6 +243,25 @@ func TestValidationStringIsWhiteSpace(t *testing.T) { } } +func TestValidationStringLenBetween(t *testing.T) { + runTestCases(t, []testCase{ + { + val: "abc", + f: StringLenBetween(1, 5), + }, + { + val: "InvalidValue", + f: StringLenBetween(1, 5), + expectedErr: regexp.MustCompile(`expected length of [\w]+ to be in the range \(1 \- 5\), got InvalidValue`), + }, + { + val: 1, + f: StringLenBetween(1, 5), + expectedErr: regexp.MustCompile(`expected type of [\w]+ to be string`), + }, + }) +} + func TestValidationStringIsBase64(t *testing.T) { cases := map[string]struct { Value interface{}