util

package
v0.0.0-...-23da319 Latest Latest
Warning

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

Go to latest
Published: May 19, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SQLInjectionRegexp = regexp.MustCompile(`(?i)[\s\p{Zs}]+|(select|union|insert|delete|update|where|drop|create|from|set|or|and|like|case|when|between|exists|in|not|order|by|group|having|limit|offset|truncate|alter|add|constraint|default|distinct|index|primary|key|references|foreign|check|cascade|inner|join|left|outer|right|cross|natural|on|using|as|asc|desc|into|values|having|asc|desc|sleep|')`)
	EmailRegexp        = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
	IsValidFullName    = regexp.MustCompile(`^[a-zA-Z\s]+$`).MatchString
)
View Source
var InterruptSignals = []os.Signal{
	os.Interrupt,
	syscall.SIGTERM,
	syscall.SIGINT,
}

Functions

func ComparePassword

func ComparePassword(password, hashedPassword string) error

func Contains

func Contains[T comparable](elems []T, v T, fn func(value T, element T) bool) bool

func ConvertToFloat64

func ConvertToFloat64(value interface{}) float64

func GenerateCacheKey

func GenerateCacheKey(prefix string, params any) string

func GenerateCacheKeyParams

func GenerateCacheKeyParams(params ...any) string

func HashPassword

func HashPassword(password string) (string, error)

func MustContainLowercase

func MustContainLowercase(password string) error

func MustContainNumber

func MustContainNumber(password string) error

func MustContainSpecialChar

func MustContainSpecialChar(password string) error

func MustContainUppercase

func MustContainUppercase(password string) error

func RandomEmail

func RandomEmail() string

RandomEmail generates a random email

func RandomInt

func RandomInt(min, max int64) int64

RandomInt generates a random integer between min and max

func RandomOwner

func RandomOwner() string

RandomOwner generates a random owner name

func RandomPhoneNumber

func RandomPhoneNumber() string

func RandomString

func RandomString(n int) string

RandomString generates a random string of length n

func RandomWebSite

func RandomWebSite() string

func SafeSQL

func SafeSQL(inputs ...string)

func ValidateEmail

func ValidateEmail(email string) error

func ValidateName

func ValidateName(name string) error

func ValidatePassword

func ValidatePassword(password string) error

func ValidatePhoneNumber

func ValidatePhoneNumber(phoneNumber string) error

func ValidateString

func ValidateString(value string, minLength int, maxLength int) error

func ValidateSurname

func ValidateSurname(name string) error

Types

type GenericList

type GenericList[T comparable] struct {
	Items []T
}

func NewGenericList

func NewGenericList[T comparable]() *GenericList[T]

func (*GenericList[T]) Add

func (gl *GenericList[T]) Add(item T)

func (*GenericList[T]) Contains

func (gl *GenericList[T]) Contains(item T) bool

func (*GenericList[T]) Get

func (gl *GenericList[T]) Get(index int) (T, error)

func (*GenericList[T]) Remove

func (gl *GenericList[T]) Remove(index int) error

func (*GenericList[T]) RemoveWithValue

func (gl *GenericList[T]) RemoveWithValue(item T)

type PasswordPolicy

type PasswordPolicy func(string) error

PasswordPolicy is a function that checks if a password meets a certain criteria.

Jump to

Keyboard shortcuts

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