Documentation
¶
Index ¶
- Constants
- func ErrEmailTooLong(max int) error
- func ErrInvalidEmail() error
- func ErrNameEmpty() error
- func ErrNameTooLong(max int) error
- func ErrPasswordTooLong(max int) error
- func ErrPasswordTooShort(min int) error
- func ErrUserNotFound() error
- func ErrUserWithEmailAlreadyExists() error
- func NewCore(repo Repository, idGenerator IDGenerator, passwordHasher PasswordHasher, ...) (*core, error)
- type Config
- type CreateUserReq
- type IDGenerator
- type PasswordHasher
- type Repository
- type UpdateUserReq
- type User
- type ValidationConfig
- type Validator
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func ErrEmailTooLong ¶
func ErrInvalidEmail ¶
func ErrInvalidEmail() error
func ErrNameEmpty ¶
func ErrNameEmpty() error
func ErrNameTooLong ¶
func ErrPasswordTooLong ¶
func ErrPasswordTooShort ¶
func ErrUserNotFound ¶
func ErrUserNotFound() error
func ErrUserWithEmailAlreadyExists ¶
func ErrUserWithEmailAlreadyExists() error
func NewCore ¶
func NewCore(repo Repository, idGenerator IDGenerator, passwordHasher PasswordHasher, validator Validator, cfg Config) (*core, error)
Types ¶
type Config ¶
type Config struct {
PasswordHashCost int `mapstructure:"password_hash_cost" json:"password_hash_cost"`
}
type CreateUserReq ¶
type IDGenerator ¶
type PasswordHasher ¶
type Repository ¶
type Repository interface {
CreateUser(ctx context.Context, req CreateUserReq, id uuid.UUID, passwordHash string) error
GetUser(ctx context.Context, id uuid.UUID) (User, string, error)
GetUserByEmail(ctx context.Context, email string) (User, string, error)
GetAllUsers(ctx context.Context) ([]User, error)
UpdateUser(ctx context.Context, req UpdateUserReq) error
DeleteUser(ctx context.Context, id uuid.UUID) error
ChangePassword(ctx context.Context, id uuid.UUID, newPasswordHash string) error
}
type UpdateUserReq ¶
type ValidationConfig ¶
type ValidationConfig struct {
MaxEmailLength int `mapstructure:"max_email_length" json:"max_email_length"`
MaxNameLength int `mapstructure:"max_name_length" json:"max_name_length"`
MinPasswordLength int `mapstructure:"min_password_length" json:"min_password_length"`
MaxPasswordLength int `mapstructure:"max_password_length" json:"max_password_length"`
}
type Validator ¶
type Validator interface {
ValidatePassword(password []byte) error
ValidateEmail(address string, validateLength bool) error
ValidateName(name string) error
NormalizeName(name string) string
NormalizeEmail(address string) string
}
func NewValidator ¶
func NewValidator(cfg ValidationConfig) (Validator, error)
Click to show internal directories.
Click to hide internal directories.