File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import (
2020
2121 "github.com/charmbracelet/huh"
2222 "github.com/goharbor/go-client/pkg/sdk/v2.0/models"
23+ "github.com/goharbor/harbor-cli/pkg/utils"
2324)
2425
2526type MemberUser struct {
@@ -85,9 +86,13 @@ func CreateMemberView(createView *CreateView) {
8586 huh .NewInput ().
8687 Title ("Username" ).
8788 Value (& createView .MemberUser .Username ).
88- Validate (func (str string ) error { // TODO: Add username checking
89+ Validate (func (str string ) error {
8990 if str == "" {
90- return errors .New ("Username and UserID cannot both be empty." )
91+ return errors .New ("Username cannot be empty." )
92+ }
93+
94+ if ! utils .ValidateUserName (str ) {
95+ return errors .New ("Invalid username. Must be 1-255 characters long and cannot contain special characters: , \" ~ # % $" )
9196 }
9297
9398 return nil
You can’t perform that action at this time.
0 commit comments