Documentation
¶
Index ¶
- Variables
- func GenerateHash(input string) string
- func GenerateUUID() uuid.UUID
- func GenerateUUIDString() string
- func HashPassword(password string) (string, error)
- func IsEmpty(s string) bool
- func IsNotEmpty(s string) bool
- func IsValidEmail(email string) bool
- func IsValidPassword(password string) bool
- func IsValidPhone(phone string) bool
- func IsValidURL(url string) bool
- func IsValidUUID(uuidStr string) bool
- func Now() time.Time
- func NowUTC() time.Time
- func VerifyPassword(password, hash string) bool
- type CryptoUtils
- type FileUtils
- func (fu *FileUtils) FormatFileSize(size int64) string
- func (fu *FileUtils) GetFileExtension(filename string) string
- func (fu *FileUtils) GetFileNameWithoutExtension(filename string) string
- func (fu *FileUtils) IsValidDocumentExtension(extension string) bool
- func (fu *FileUtils) IsValidImageExtension(extension string) bool
- type LogUtils
- func (lu *LogUtils) LogDebug(message string, fields logrus.Fields)
- func (lu *LogUtils) LogError(err error, message string, fields logrus.Fields)
- func (lu *LogUtils) LogInfo(message string, fields logrus.Fields)
- func (lu *LogUtils) LogWarning(message string, fields logrus.Fields)
- func (lu *LogUtils) LogWithDuration(message string, duration time.Duration, fields logrus.Fields)
- func (lu *LogUtils) LogWithRequest(message string, requestID, method, path string, fields logrus.Fields)
- func (lu *LogUtils) LogWithUser(message string, userID, tenantID string, fields logrus.Fields)
- type StringUtils
- func (su *StringUtils) Capitalize(s string) string
- func (su *StringUtils) Contains(s, substr string) bool
- func (su *StringUtils) IsEmpty(s string) bool
- func (su *StringUtils) IsNotEmpty(s string) bool
- func (su *StringUtils) RandomString(length int) string
- func (su *StringUtils) Slugify(s string) string
- func (su *StringUtils) TitleCase(s string) string
- func (su *StringUtils) Truncate(s string, length int) string
- type TimeUtils
- func (tu *TimeUtils) AddDays(t time.Time, days int) time.Time
- func (tu *TimeUtils) AddMonths(t time.Time, months int) time.Time
- func (tu *TimeUtils) AddYears(t time.Time, years int) time.Time
- func (tu *TimeUtils) FormatTime(t time.Time, layout string) string
- func (tu *TimeUtils) GetEndOfDay(t time.Time) time.Time
- func (tu *TimeUtils) GetEndOfMonth(t time.Time) time.Time
- func (tu *TimeUtils) GetEndOfWeek(t time.Time) time.Time
- func (tu *TimeUtils) GetEndOfYear(t time.Time) time.Time
- func (tu *TimeUtils) GetStartOfDay(t time.Time) time.Time
- func (tu *TimeUtils) GetStartOfMonth(t time.Time) time.Time
- func (tu *TimeUtils) GetStartOfWeek(t time.Time) time.Time
- func (tu *TimeUtils) GetStartOfYear(t time.Time) time.Time
- func (tu *TimeUtils) IsThisMonth(t time.Time) bool
- func (tu *TimeUtils) IsThisWeek(t time.Time) bool
- func (tu *TimeUtils) IsThisYear(t time.Time) bool
- func (tu *TimeUtils) IsToday(t time.Time) bool
- func (tu *TimeUtils) IsYesterday(t time.Time) bool
- func (tu *TimeUtils) Now() time.Time
- func (tu *TimeUtils) NowUTC() time.Time
- func (tu *TimeUtils) ParseTime(timeStr, layout string) (time.Time, error)
- type UUIDUtils
- type ValidationUtils
- func (vu *ValidationUtils) IsValidEmail(email string) bool
- func (vu *ValidationUtils) IsValidPassword(password string) bool
- func (vu *ValidationUtils) IsValidPhone(phone string) bool
- func (vu *ValidationUtils) IsValidURL(url string) bool
- func (vu *ValidationUtils) IsValidUUID(uuidStr string) bool
- func (vu *ValidationUtils) ValidatePasswordWithDetails(password string) (bool, []string)
Constants ¶
This section is empty.
Variables ¶
var ( StringUtilsInstance = NewStringUtils() ValidationUtilsInstance = NewValidationUtils() CryptoUtilsInstance = NewCryptoUtils() TimeUtilsInstance = NewTimeUtils() UUIDUtilsInstance = NewUUIDUtils() FileUtilsInstance = NewFileUtils() )
Global utility instances for backward compatibility
Functions ¶
func GenerateHash ¶
func GenerateUUID ¶
func GenerateUUIDString ¶
func GenerateUUIDString() string
func HashPassword ¶
func IsNotEmpty ¶
func IsValidEmail ¶
func IsValidPassword ¶
func IsValidPhone ¶
func IsValidURL ¶
func IsValidUUID ¶
func VerifyPassword ¶
Types ¶
type CryptoUtils ¶
type CryptoUtils struct{}
CryptoUtils provides cryptographic utility functions
func NewCryptoUtils ¶
func NewCryptoUtils() *CryptoUtils
NewCryptoUtils creates a new CryptoUtils instance
func (*CryptoUtils) GenerateHash ¶
func (cu *CryptoUtils) GenerateHash(input string) string
GenerateHash generates a SHA256 hash of the input string
func (*CryptoUtils) GenerateRandomBytes ¶
func (cu *CryptoUtils) GenerateRandomBytes(length int) ([]byte, error)
GenerateRandomBytes generates random bytes of specified length
func (*CryptoUtils) HashPassword ¶
func (cu *CryptoUtils) HashPassword(password string) (string, error)
HashPassword hashes a password using bcrypt
func (*CryptoUtils) VerifyPassword ¶
func (cu *CryptoUtils) VerifyPassword(password, hash string) bool
VerifyPassword verifies a password against its hash
type FileUtils ¶
type FileUtils struct{}
FileUtils provides file utility functions
func (*FileUtils) FormatFileSize ¶
FormatFileSize formats a file size in bytes to human readable format
func (*FileUtils) GetFileExtension ¶
GetFileExtension gets the file extension from a filename
func (*FileUtils) GetFileNameWithoutExtension ¶
GetFileNameWithoutExtension gets the filename without extension
func (*FileUtils) IsValidDocumentExtension ¶
IsValidDocumentExtension checks if a file extension is a valid document extension
func (*FileUtils) IsValidImageExtension ¶
IsValidImageExtension checks if a file extension is a valid image extension
type LogUtils ¶
type LogUtils struct {
// contains filtered or unexported fields
}
LogUtils provides logging utility functions
func NewLogUtils ¶
NewLogUtils creates a new LogUtils instance
func (*LogUtils) LogWarning ¶
LogWarning logs a warning message with context
func (*LogUtils) LogWithDuration ¶
LogWithDuration logs a message with duration
type StringUtils ¶
type StringUtils struct{}
StringUtils provides string utility functions
func NewStringUtils ¶
func NewStringUtils() *StringUtils
NewStringUtils creates a new StringUtils instance
func (*StringUtils) Capitalize ¶
func (su *StringUtils) Capitalize(s string) string
Capitalize capitalizes the first letter of a string
func (*StringUtils) Contains ¶
func (su *StringUtils) Contains(s, substr string) bool
Contains checks if a string contains a substring (case-insensitive)
func (*StringUtils) IsEmpty ¶
func (su *StringUtils) IsEmpty(s string) bool
IsEmpty checks if a string is empty or contains only whitespace
func (*StringUtils) IsNotEmpty ¶
func (su *StringUtils) IsNotEmpty(s string) bool
IsNotEmpty checks if a string is not empty
func (*StringUtils) RandomString ¶
func (su *StringUtils) RandomString(length int) string
RandomString generates a random string of specified length
func (*StringUtils) Slugify ¶
func (su *StringUtils) Slugify(s string) string
Slugify converts a string to a URL-friendly slug
func (*StringUtils) TitleCase ¶
func (su *StringUtils) TitleCase(s string) string
TitleCase converts a string to title case
type TimeUtils ¶
type TimeUtils struct{}
TimeUtils provides time utility functions
func (*TimeUtils) FormatTime ¶
FormatTime formats a time using the specified layout
func (*TimeUtils) GetEndOfDay ¶
GetEndOfDay returns the end of the day for a given time
func (*TimeUtils) GetEndOfMonth ¶
GetEndOfMonth returns the end of the month for a given time
func (*TimeUtils) GetEndOfWeek ¶
GetEndOfWeek returns the end of the week for a given time
func (*TimeUtils) GetEndOfYear ¶
GetEndOfYear returns the end of the year for a given time
func (*TimeUtils) GetStartOfDay ¶
GetStartOfDay returns the start of the day for a given time
func (*TimeUtils) GetStartOfMonth ¶
GetStartOfMonth returns the start of the month for a given time
func (*TimeUtils) GetStartOfWeek ¶
GetStartOfWeek returns the start of the week for a given time
func (*TimeUtils) GetStartOfYear ¶
GetStartOfYear returns the start of the year for a given time
func (*TimeUtils) IsThisMonth ¶
IsThisMonth checks if a time is this month
func (*TimeUtils) IsThisWeek ¶
IsThisWeek checks if a time is this week
func (*TimeUtils) IsThisYear ¶
IsThisYear checks if a time is this year
func (*TimeUtils) IsYesterday ¶
IsYesterday checks if a time is yesterday
type UUIDUtils ¶
type UUIDUtils struct{}
UUIDUtils provides UUID utility functions
func (*UUIDUtils) GenerateString ¶
GenerateString generates a new UUID as a string
type ValidationUtils ¶
type ValidationUtils struct{}
ValidationUtils provides validation utility functions
func NewValidationUtils ¶
func NewValidationUtils() *ValidationUtils
NewValidationUtils creates a new ValidationUtils instance
func (*ValidationUtils) IsValidEmail ¶
func (vu *ValidationUtils) IsValidEmail(email string) bool
IsValidEmail validates an email address
func (*ValidationUtils) IsValidPassword ¶
func (vu *ValidationUtils) IsValidPassword(password string) bool
IsValidPassword validates a password with strong requirements
func (*ValidationUtils) IsValidPhone ¶
func (vu *ValidationUtils) IsValidPhone(phone string) bool
IsValidPhone validates a phone number
func (*ValidationUtils) IsValidURL ¶
func (vu *ValidationUtils) IsValidURL(url string) bool
IsValidURL validates a URL
func (*ValidationUtils) IsValidUUID ¶
func (vu *ValidationUtils) IsValidUUID(uuidStr string) bool
IsValidUUID validates a UUID
func (*ValidationUtils) ValidatePasswordWithDetails ¶ added in v1.1.1
func (vu *ValidationUtils) ValidatePasswordWithDetails(password string) (bool, []string)
ValidatePasswordWithDetails validates a password and returns detailed error messages