valueobjects

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

StatusTransitions defines allowed status transitions

ValidStatuses contains all valid status values

Functions

This section is empty.

Types

type Email

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

Email represents an email address value object

func NewEmail

func NewEmail(value string) (*Email, error)

NewEmail creates a new Email value object with validation

func (*Email) Domain

func (e *Email) Domain() string

Domain returns the domain part of the email

func (*Email) Equals

func (e *Email) Equals(other *Email) bool

Equals checks if two email objects are equal

func (*Email) IsBusinessEmail

func (e *Email) IsBusinessEmail() bool

IsBusinessEmail checks if the email is from a business domain (not free email providers)

func (*Email) LocalPart

func (e *Email) LocalPart() string

LocalPart returns the local part of the email (before @)

func (Email) MarshalJSON

func (e Email) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface

func (*Email) String

func (e *Email) String() string

String returns the string representation of the email

func (*Email) UnmarshalJSON

func (e *Email) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface

type Name

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

Name represents a person's name value object

func NewName

func NewName(value string) (*Name, error)

NewName creates a new Name value object with validation

func (*Name) DisplayName

func (n *Name) DisplayName() string

DisplayName returns a formatted display name

func (*Name) Equals

func (n *Name) Equals(other *Name) bool

Equals checks if two name objects are equal

func (*Name) FirstName

func (n *Name) FirstName() string

FirstName returns the first name part

func (*Name) Initials

func (n *Name) Initials() string

Initials returns the initials of the name

func (*Name) IsMononym

func (n *Name) IsMononym() bool

IsMononym checks if the name is a single name (mononym)

func (*Name) LastName

func (n *Name) LastName() string

LastName returns the last name part

func (Name) MarshalJSON

func (n Name) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface

func (*Name) MiddleNames

func (n *Name) MiddleNames() []string

MiddleNames returns the middle names if any

func (*Name) String

func (n *Name) String() string

String returns the string representation of the name

func (*Name) UnmarshalJSON

func (n *Name) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface

type Password

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

func NewPassword

func NewPassword(plainPassword string) (*Password, error)

func NewPasswordWithPolicy added in v0.1.78

func NewPasswordWithPolicy(plainPassword string, policy *PasswordPolicy) (*Password, error)

NewPasswordWithPolicy creates a new password value object with custom policy

func (*Password) String

func (p *Password) String() string

type PasswordPolicy added in v0.1.78

type PasswordPolicy struct {
	MinLength        int
	RequireUppercase bool
	RequireLowercase bool
	RequireNumber    bool
	RequireSpecial   bool
}

PasswordPolicy defines the password validation rules

func DefaultPasswordPolicy added in v0.1.78

func DefaultPasswordPolicy() *PasswordPolicy

DefaultPasswordPolicy returns the default password policy with strong complexity requirements

func (*PasswordPolicy) ValidatePassword added in v0.1.78

func (p *PasswordPolicy) ValidatePassword(password string) error

ValidatePassword validates password against the policy

type Status

type Status string

Status represents the user status value object

const (
	StatusActive    Status = "active"
	StatusInactive  Status = "inactive"
	StatusPending   Status = "pending"
	StatusSuspended Status = "suspended"
	StatusDeleted   Status = "deleted"
)

Status constants

func NewStatus

func NewStatus(value string) (*Status, error)

NewStatus creates a new Status value object with validation

func ParseStatus

func ParseStatus(value string) (Status, error)

ParseStatus parses a string to Status (case-insensitive)

func (Status) CanPerformActions

func (s Status) CanPerformActions() bool

CanPerformActions checks if a user with this status can perform actions

func (Status) CanTransitionTo

func (s Status) CanTransitionTo(target Status) bool

CanTransitionTo checks if the current status can transition to the target status

func (Status) Equals

func (s Status) Equals(other Status) bool

Equals checks if two status objects are equal

func (Status) GetAllowedTransitions

func (s Status) GetAllowedTransitions() []Status

GetAllowedTransitions returns all allowed transitions from the current status

func (Status) IsActive

func (s Status) IsActive() bool

IsActive checks if the status is active

func (Status) IsDeleted

func (s Status) IsDeleted() bool

IsDeleted checks if the status is deleted

func (Status) IsInactive

func (s Status) IsInactive() bool

IsInactive checks if the status is inactive

func (Status) IsPending

func (s Status) IsPending() bool

IsPending checks if the status is pending

func (Status) IsSuspended

func (s Status) IsSuspended() bool

IsSuspended checks if the status is suspended

func (Status) IsTerminal

func (s Status) IsTerminal() bool

IsTerminal checks if the status is terminal (no further transitions possible)

func (Status) MarshalJSON

func (s Status) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface

func (Status) RequiresVerification

func (s Status) RequiresVerification() bool

RequiresVerification checks if the status requires verification before activation

func (Status) String

func (s Status) String() string

String returns the string representation of the status

func (*Status) TransitionTo

func (s *Status) TransitionTo(target Status) error

TransitionTo attempts to transition to a new status

func (*Status) UnmarshalJSON

func (s *Status) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface

type Token

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

func GenerateToken

func GenerateToken() (*Token, error)

func NewTokenFromValue

func NewTokenFromValue(value string) (*Token, error)

func (*Token) Hash

func (t *Token) Hash() string

func (*Token) Value

func (t *Token) Value() string

func (*Token) Verify

func (t *Token) Verify(plainToken string) bool

Jump to

Keyboard shortcuts

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