Skip to content

Commit

Permalink
chore: remove govalidator lib usage
Browse files Browse the repository at this point in the history
Replace with a single regex
  • Loading branch information
nvloff-f3 committed Mar 7, 2024
1 parent fadf506 commit b264e82
Show file tree
Hide file tree
Showing 20 changed files with 7 additions and 3,925 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ go 1.20

require (
github.com/aholic/ggtimer v0.0.0-20150905131044-5d7b30837a52
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2
github.com/avast/retry-go/v4 v4.5.1
github.com/chobie/go-gaussian v0.0.0-20150107165016-53c09d90eeaf
github.com/evalphobia/logrus_fluent v0.5.4
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
github.com/aholic/ggtimer v0.0.0-20150905131044-5d7b30837a52 h1:PuAAatjhSeWL+ybYPp3eAZ88we2mHZ/b4l/YUzIwpAw=
github.com/aholic/ggtimer v0.0.0-20150905131044-5d7b30837a52/go.mod h1:dn/mVOaud2SCQOekwuqMOnheqP2Cu3cCYe/pN3TWNPA=
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so=
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
github.com/avast/retry-go/v4 v4.5.1 h1:AxIx0HGi4VZ3I02jr78j5lZ3M6x1E0Ivxa6b0pUUh7o=
github.com/avast/retry-go/v4 v4.5.1/go.mod h1:/sipNsvNB3RRuT5iNcb6h73nw3IBmXJ/H3XrCQYSOpc=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
Expand Down
10 changes: 7 additions & 3 deletions internal/trigger/rate/rate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ package rate

import (
"fmt"
"regexp"
"strconv"
"strings"
"time"

"github.com/asaskevich/govalidator"
)

func ParseRate(rateArg string) (int, time.Duration, error) {
Expand All @@ -23,7 +22,7 @@ func ParseRate(rateArg string) (int, time.Duration, error) {
return rate, unit, fmt.Errorf("invalid rate arg %s", rateArg)
}
unitArg := (rateArg)[strings.Index(rateArg, "/")+1:]
if !govalidator.IsNumeric(unitArg[0:1]) {
if !isNumeric(unitArg[0:1]) {
unitArg = "1" + unitArg
}
unit, err = time.ParseDuration(unitArg)
Expand All @@ -44,3 +43,8 @@ func ParseRate(rateArg string) (int, time.Duration, error) {

return rate, unit, nil
}

func isNumeric(value string) bool {
re := regexp.MustCompile("^[0-9]+$")
return re.MatchString(value)
}
15 changes: 0 additions & 15 deletions vendor/github.com/asaskevich/govalidator/.gitignore

This file was deleted.

12 changes: 0 additions & 12 deletions vendor/github.com/asaskevich/govalidator/.travis.yml

This file was deleted.

43 changes: 0 additions & 43 deletions vendor/github.com/asaskevich/govalidator/CODE_OF_CONDUCT.md

This file was deleted.

63 changes: 0 additions & 63 deletions vendor/github.com/asaskevich/govalidator/CONTRIBUTING.md

This file was deleted.

21 changes: 0 additions & 21 deletions vendor/github.com/asaskevich/govalidator/LICENSE

This file was deleted.

Loading

0 comments on commit b264e82

Please sign in to comment.