Documentation
¶
Index ¶
- func ComparePassword(hashedPassword, password string) bool
- func HashPassword(password string) (string, error)
- func ValidateEmail(email string) bool
- func ValidatePassword(password string, config *PasswordValidationConfig) error
- type AddPasswordSpecialCharValidator
- type AddPasswordStrengthValidator
- type PasswordValidationConfig
- type PasswordValidator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComparePassword ¶
ComparePassword compares a hashed password with the plaintext password
func HashPassword ¶
HashPassword hashes a plaintext password using bcrypt
func ValidateEmail ¶
ValidateEmail checks if the email format is valid
func ValidatePassword ¶
func ValidatePassword(password string, config *PasswordValidationConfig) error
ValidatePassword checks if the password meets the minimum length and passes additional validations
Types ¶
type AddPasswordSpecialCharValidator ¶
type AddPasswordSpecialCharValidator struct{}
AddPasswordSpecialCharValidator checks if the password contains at least one special character
func (*AddPasswordSpecialCharValidator) Validate ¶
func (v *AddPasswordSpecialCharValidator) Validate(password string) error
Validate checks if the password has at least one special character
type AddPasswordStrengthValidator ¶
type AddPasswordStrengthValidator struct{}
AddPasswordStrengthValidator checks if the password contains at least one uppercase letter and one number
func (*AddPasswordStrengthValidator) Validate ¶
func (v *AddPasswordStrengthValidator) Validate(password string) error
Validate checks if the password has at least one uppercase letter and one number
type PasswordValidationConfig ¶
type PasswordValidationConfig struct {
MinLength int
Validators []PasswordValidator // Additional validators like strength check, etc.
}
PasswordValidationConfig holds the configuration for validating passwords
func NewPasswordValidationConfig ¶
func NewPasswordValidationConfig(minLength ...int) *PasswordValidationConfig
NewPasswordValidationConfig creates a new PasswordValidationConfig with default values
type PasswordValidator ¶
PasswordValidator is an interface for custom password validation strategies