utils

package
v0.0.0-...-e4b55f4 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CurrentWeekdayStrategy = WeekDayStrategy{
	// contains filtered or unexported fields
}

Functions

func BlurEmailAddress

func BlurEmailAddress(email string) string

BlurEmailAddress transforms an email address to reduce exposed personal info

func CheckEmailFormat

func CheckEmailFormat(email string) bool

CheckEmailFormat to check if input string is a correct email address

func CheckLanguageCode

func CheckLanguageCode(code string) bool

CheckLanguageCode checks if a string can be considered as a language code

func CheckPasswordFormat

func CheckPasswordFormat(password string) bool

CheckPasswordFormat to check if password fulfills password rules

func GenerateOTPCode

func GenerateOTPCode(length int) (string, error)

GenerateOTPCode generates a random OTP code of the given length

func GenerateUniqueTokenString

func GenerateUniqueTokenString() (string, error)

func GetExpirationTime

func GetExpirationTime(validityPeriod time.Duration) time.Time

func GetMainAndOtherProfiles

func GetMainAndOtherProfiles(user userTypes.User) (mainProfileID string, otherProfileIDs []string)

GetMainAndOtherProfiles extract main profile ID and secondary profiles from a user account info

func HasMoreAttemptsRecently

func HasMoreAttemptsRecently(attempts []int64, moreThan int, intervalSeconds int64) bool

func InitNewEmailUser

func InitNewEmailUser(
	email string,
	password string,
	locale string,
) userTypes.User

func InitWeekdayAssignationStrategy

func InitWeekdayAssignationStrategy(
	weekdayAssignation map[string]int,
)

func InitWeekdayAssignationStrategyFromEnv

func InitWeekdayAssignationStrategyFromEnv(
	envWeekdayAssignation string,
)

func ParseWeeklyWeight

func ParseWeeklyWeight(str string) ([]int, error)

ParseWeeklyWeight parse a string attributing a weight for each day of the week Expected format is a comma separated assignation with [DayName]=Weight with DayName = Mon,Tue,Web,Thu,Frid,Sat,Sun (case insensitive) Weight is a positive integer value or Zero

func ReachedExpirationTime

func ReachedExpirationTime(t time.Time) bool

func RemoveAttemptsOlderThan

func RemoveAttemptsOlderThan(attempts []int64, olderThanSeconds int64) []int64

func SanitizeEmail

func SanitizeEmail(email string) string

Types

type Interval

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

type WeekDayStrategy

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

func CreateWeekdayDefaultStrategy

func CreateWeekdayDefaultStrategy() WeekDayStrategy

func CreateWeekdayWeightedStrategy

func CreateWeekdayWeightedStrategy(weights []int) WeekDayStrategy

func (*WeekDayStrategy) String

func (s *WeekDayStrategy) String() string

func (*WeekDayStrategy) Weekday

func (s *WeekDayStrategy) Weekday() int

Assign a new weekday using the assignation strategy

type Weight

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

Weekday assignation strategy

func CreateWeight

func CreateWeight(w []int) Weight

CreateWeight creates a weighted structure to handle the weighted assignation

func (*Weight) Lookup

func (w *Weight) Lookup(value int) int

Lookup computes the entry Value is expected from 0..total-1

func (*Weight) String

func (w *Weight) String() string

Jump to

Keyboard shortcuts

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