Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: hunter007 <[email protected]>
hunter007 committed Jun 1, 2023
1 parent 1302380 commit dbd2ed3
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion errors.go
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ var errMinMax = errors.New("min_length should less than max_length")
var errMin = errors.New("min_length should more than 0")

// MinLength should more than 0
var errMax = errors.New("min_length should more than 0")
var errMax = errors.New(fmt.Sprintf("max_length should less than %d", maxLengthPassword))

// This password is too common
var errCommon = errors.New("this password is too common")
4 changes: 3 additions & 1 deletion validator.go
Original file line number Diff line number Diff line change
@@ -51,12 +51,14 @@ func (opt *ValidatorOption) loadCommonPasswords() error {
return nil
}

const maxLengthPassword = 32

func (opt *ValidatorOption) validate() error {
if opt.MinLength <= 0 {
return errMin
}

if opt.MaxLength >= 32 {
if opt.MaxLength >= maxLengthPassword {
return errMax
}

0 comments on commit dbd2ed3

Please sign in to comment.