fixed arg validation

This commit is contained in:
Gani Georgiev committed 2026-07-15 13:23:13 +03:00
1 parent 84c2c558da
commit a6deb6ab90
2 files changed
+11 -1

No files matched your search

+1 -1
View File
@@ -47,7 +47,7 @@ func newExcerptModifier(args ...string) (*excerptModifier, error) {
} }
max := cast.ToInt(args[0]) max := cast.ToInt(args[0])
if max == 0 { if max <= 0 {
return nil, errors.New("max argument must be > 0") return nil, errors.New("max argument must be > 0")
} }
+10
View File
@@ -28,6 +28,16 @@ func TestNewExcerptModifier(t *testing.T) {
[]string{"something"}, // should fallback to 0 which is not allowed []string{"something"}, // should fallback to 0 which is not allowed
true, true,
}, },
{
"negative numeric max argument",
[]string{"-1"},
true,
},
{
"zero numeric max argument",
[]string{"0"},
true,
},
{ {
"numeric max argument", "numeric max argument",
[]string{"12"}, []string{"12"},