1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-23 15:29:42 +02:00

fix(govalidator): replace govalidator dependency [BE-11574] (#673)

This commit is contained in:
Devon Steenberg 2025-04-23 13:59:51 +12:00 committed by GitHub
parent 3edacee59b
commit 1a3df54c04
18 changed files with 571 additions and 43 deletions

View file

@ -11,8 +11,7 @@ import (
httperror "github.com/portainer/portainer/pkg/libhttp/error"
"github.com/portainer/portainer/pkg/libhttp/request"
"github.com/portainer/portainer/pkg/libhttp/response"
"github.com/asaskevich/govalidator"
"github.com/portainer/portainer/pkg/validate"
)
type userAccessTokenCreatePayload struct {
@ -24,10 +23,10 @@ func (payload *userAccessTokenCreatePayload) Validate(r *http.Request) error {
if len(payload.Description) == 0 {
return errors.New("invalid description: cannot be empty")
}
if govalidator.HasWhitespaceOnly(payload.Description) {
if validate.HasWhitespaceOnly(payload.Description) {
return errors.New("invalid description: cannot contain only whitespaces")
}
if govalidator.MinStringLength(payload.Description, "128") {
if validate.MinStringLength(payload.Description, 128) {
return errors.New("invalid description: cannot be longer than 128 characters")
}
return nil