Documentation ¶
Index ¶
- Constants
- type Result
- type Validator
- func (v *Validator) SetDict(dict []string)
- func (v *Validator) SetHibpClientContext(ctx context.Context)
- func (v *Validator) SetHibpThreshold(threshold int)
- func (v *Validator) SetIgnoreHibpError(flag bool)
- func (v *Validator) SetLevenshteinThreshold(threshold int)
- func (v *Validator) SetMaxLength(length int)
- func (v *Validator) SetMinLength(length int)
- func (v *Validator) Validate(password string) (result Result, err error)
Constants ¶
View Source
const ( DefaultMinLength = 8 // Default minimum length of the password. DefaultMaxLength = 64 // Default maximum length of the password. DefaultHibpThreshold = 0 // Default threshold of HIBP count for the password. DefaultLevenshteinThreshold = 2 // Default threshold of the Levenshtein distance to the dictionary for the password. )
View Source
const (
HibpApiBaseURL = "https://api.pwnedpasswords.com"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Result ¶
type Result int
Result of the validation.
const ( Ok Result // Validation OK ViolateMinLengthCheck // Violate minimum length check. ViolateMaxLengthCheck // Violate maximum length check. ViolateDictCheck // Violate dictionary check. ViolateHibpCheck // Violate HIBP check. Error // Validation Error )
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator
func (*Validator) SetHibpClientContext ¶
SetHibpClientContext set context.Context for the request to HIBP.
func (*Validator) SetHibpThreshold ¶
SetHibpThreshold set threshold of HIBP count for the password.
func (*Validator) SetIgnoreHibpError ¶
SetIgnoreHibpError set the flag for ignore hibp error. (not recommended)
func (*Validator) SetLevenshteinThreshold ¶
SetLevenshteinThreshold set threshold of the Levenshtein distance to the dictionary for the password.
func (*Validator) SetMaxLength ¶
SetMaxLength set maximum length of the password.
func (*Validator) SetMinLength ¶
SetMinLength set minimum length of the password.
Click to show internal directories.
Click to hide internal directories.