Skip to content

Commit 665baff

Browse files
committed
Added test for StringLenBetween
1 parent 091d9ea commit 665baff

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Diff for: helper/validation/strings_test.go

+19
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,25 @@ func TestValidationStringIsWhiteSpace(t *testing.T) {
243243
}
244244
}
245245

246+
func TestValidationStringLenBetween(t *testing.T) {
247+
runTestCases(t, []testCase{
248+
{
249+
val: "abc",
250+
f: StringLenBetween(1, 5),
251+
},
252+
{
253+
val: "InvalidValue",
254+
f: StringLenBetween(1, 5),
255+
expectedErr: regexp.MustCompile(`expected length of [\w]+ to be in the range \(1 \- 5\), got InvalidValue`),
256+
},
257+
{
258+
val: 1,
259+
f: StringLenBetween(1, 5),
260+
expectedErr: regexp.MustCompile(`expected type of [\w]+ to be string`),
261+
},
262+
})
263+
}
264+
246265
func TestValidationStringIsBase64(t *testing.T) {
247266
cases := map[string]struct {
248267
Value interface{}

0 commit comments

Comments
 (0)