Function
checkPasswordPattern
(fl validator.FieldLevel)
Source from the content-addressed store, hash-verified
| 34 | } |
| 35 | |
| 36 | func checkPasswordPattern(fl validator.FieldLevel) bool { |
| 37 | value := fl.Field().String() |
| 38 | if len(value) < 8 || len(value) > 30 { |
| 39 | return false |
| 40 | } |
| 41 | |
| 42 | hasNum := false |
| 43 | hasLetter := false |
| 44 | for _, r := range value { |
| 45 | if unicode.IsLetter(r) && !hasLetter { |
| 46 | hasLetter = true |
| 47 | } |
| 48 | if unicode.IsNumber(r) && !hasNum { |
| 49 | hasNum = true |
| 50 | } |
| 51 | if hasLetter && hasNum { |
| 52 | return true |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | return false |
| 57 | } |
Callers
nothing calls this directly
Tested by
no test coverage detected