Skip to content

Commit

Permalink
Add ValidatePassword function
Browse files Browse the repository at this point in the history
  • Loading branch information
genedna committed Jul 4, 2015
1 parent 11a0f90 commit f2fb425
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/base64"
"fmt"
"os"
"regexp"
"strings"
)

Expand Down Expand Up @@ -60,3 +61,19 @@ func IsDirExists(path string) bool {

panic("not reached")
}

func ValidatePassword(password string) error {
if valida, _ := regexp.MatchString("[:alpha:]", password); valida != true {
return fmt.Errorf("No alpha character in the password.")
}

if valida, _ := regexp.MatchString("[:digit:]", password); valida != true {
return fmt.Errorf("No digital character in the password.")
}

if len(password) < 5 || len(password) > 30 {
return fmt.Errorf("Password characters length should be between 5 - 30.")
}

return nil
}

0 comments on commit f2fb425

Please sign in to comment.