mirror of
https://github.com/pocketbase/pocketbase.git
synced 2026-08-01 19:07:50 -04:00
fixed arg validation
This commit is contained in:
@@ -47,7 +47,7 @@ func newExcerptModifier(args ...string) (*excerptModifier, error) {
|
||||
}
|
||||
|
||||
max := cast.ToInt(args[0])
|
||||
if max == 0 {
|
||||
if max <= 0 {
|
||||
return nil, errors.New("max argument must be > 0")
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,16 @@ func TestNewExcerptModifier(t *testing.T) {
|
||||
[]string{"something"}, // should fallback to 0 which is not allowed
|
||||
true,
|
||||
},
|
||||
{
|
||||
"negative numeric max argument",
|
||||
[]string{"-1"},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"zero numeric max argument",
|
||||
[]string{"0"},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"numeric max argument",
|
||||
[]string{"12"},
|
||||
|
||||
Reference in New Issue
Block a user