user

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUserNotFound = errors.New("user not found")
)

Error types for user operations

Functions

func ValidateCreateUserRequest

func ValidateCreateUserRequest(req *CreateUserRequest) error

ValidateCreateUserRequest validates a create user request

func ValidateEmail

func ValidateEmail(email string) error

ValidateEmail validates an email address format

func ValidateUpdateUserRequest

func ValidateUpdateUserRequest(req *UpdateUserRequest) error

ValidateUpdateUserRequest validates an update user request

Types

type CreateUserRequest

type CreateUserRequest struct {
	Name  string  `json:"name"`
	Email string  `json:"email"`
	Image *string `json:"image"`
}

CreateUserRequest represents a request to create a new user

type Repository

type Repository interface {
	// Create creates a new user
	Create(user *User) error

	// FindByID retrieves a user by ID
	FindByID(id string) (*User, error)

	// FindByEmail retrieves a user by email
	FindByEmail(email string) (*User, error)

	// Update updates an existing user
	Update(user *User) error

	// Delete deletes a user by ID
	Delete(id string) error

	// List lists users with pagination
	List(limit int, offset int) ([]*User, error)

	// Count returns the total number of users
	Count() (int, error)

	// ExistsByEmail checks if a user exists by email
	ExistsByEmail(email string) (bool, error)

	// ExistsByID checks if a user exists by ID
	ExistsByID(id string) (bool, error)
}

Repository defines the interface for user data access

type UpdateUserRequest

type UpdateUserRequest struct {
	Name  *string `json:"name"`
	Image *string `json:"image"`
}

UpdateUserRequest represents a request to update an existing user

type User

type User struct {
	ID            string    `json:"id"`
	Name          string    `json:"name"`
	Email         string    `json:"email"`
	EmailVerified bool      `json:"email_verified"`
	Image         *string   `json:"image"`
	CreatedAt     time.Time `json:"created_at"`
	UpdatedAt     time.Time `json:"updated_at"`
}

User represents an authenticated user in the system

Jump to

Keyboard shortcuts

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