Skip to content

Commit

Permalink
Merge pull request #33 from calyptia/fix-valid-size
Browse files Browse the repository at this point in the history
fix valid size
  • Loading branch information
niedbalski authored Sep 21, 2022
2 parents 6f381e8 + 0239158 commit d8960a4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,12 @@ func validByteSize(prop Field) bool {
return true
}

// try with number as string
if len(prop.Values) == 1 && prop.Values[0].String != nil {
_, err := strconv.ParseInt(*prop.Values[0].String, 10, 64)
return err == nil
}

// try with bytes parser.
_, err := bytefmt.ToBytes(prop.Values.ToString())
if err == nil {
Expand Down
8 changes: 8 additions & 0 deletions validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,14 @@ func TestConfigSection_Validate(t *testing.T) {
kind: NoneSection,
want: `unsupported plugin kind "NONE"`,
},
{
name: "input_forward_buffer_max_size_size",
kind: InputSection,
props: map[string]string{
"Name": "forward",
"buffer_max_size": "61440000",
},
},
}
for _, tc := range tt {
t.Run(tc.name, func(t *testing.T) {
Expand Down

0 comments on commit d8960a4

Please sign in to comment.