changes...
This commit is contained in:
parent
41944884b4
commit
ab4b53fd40
26 changed files with 600 additions and 51 deletions
25
internal/utils/password_validator.go
Normal file
25
internal/utils/password_validator.go
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
package utils
|
||||
|
||||
import (
|
||||
"unicode"
|
||||
|
||||
"github.com/go-playground/validator/v10"
|
||||
)
|
||||
|
||||
func PasswordValidator(fl validator.FieldLevel) bool {
|
||||
password := fl.Field().Interface().(string)
|
||||
|
||||
var hasUpper, hasNumber, hasLower = false, false, false
|
||||
|
||||
for _, c := range password {
|
||||
if unicode.IsUpper(c) {
|
||||
hasUpper = true
|
||||
} else if unicode.IsLower(c) {
|
||||
hasLower = true
|
||||
} else if unicode.IsDigit(c) {
|
||||
hasNumber = true
|
||||
}
|
||||
}
|
||||
|
||||
return hasUpper && hasNumber && hasLower
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue