validation

package
v0.4.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPasswordTooShort = errors.New("password is too short")
	ErrPasswordTooLong  = errors.New("password is too long")
	ErrMissingUppercase = errors.New("password must contain at least one uppercase letter")
	ErrMissingLowercase = errors.New("password must contain at least one lowercase letter")
	ErrMissingNumber    = errors.New("password must contain at least one number")
	ErrMissingSpecial   = errors.New("password must contain at least one special character")
	ErrContainsUsername = errors.New("password cannot contain the username")
	ErrCommonPassword   = errors.New("password is too common")
	ErrConsecutiveChars = errors.New("password contains consecutive repeated characters")
	ErrSequentialChars  = errors.New("password contains sequential characters")
)

Functions

This section is empty.

Types

type PasswordPolicy

type PasswordPolicy struct {
	MinLength           int
	MaxLength           int
	RequireUppercase    bool
	RequireLowercase    bool
	RequireNumbers      bool
	RequireSpecial      bool
	MaxRepeatingChars   int
	PreventSequential   bool
	PreventUsernamePart bool
}

func DefaultPasswordPolicy

func DefaultPasswordPolicy() PasswordPolicy

DefaultPasswordPolicy returns a recommended password policy

type PasswordValidator

type PasswordValidator struct {
	// contains filtered or unexported fields
}

func NewPasswordValidator

func NewPasswordValidator(policy PasswordPolicy) *PasswordValidator

func (*PasswordValidator) ValidatePassword

func (v *PasswordValidator) ValidatePassword(password string, username string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL