utils

package
v0.0.0-...-b8be85b Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComparePassword

func ComparePassword(hashedPassword, password string) bool

ComparePassword compares a hashed password with the plaintext password

func HashPassword

func HashPassword(password string) (string, error)

HashPassword hashes a plaintext password using bcrypt

func ValidateEmail

func ValidateEmail(email string) bool

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

type PasswordValidator interface {
	Validate(password string) error
}

PasswordValidator is an interface for custom password validation strategies

Jump to

Keyboard shortcuts

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