Documentation ¶
Index ¶
- Constants
- func ContainsAny(str string, chars []string) bool
- func ContainsNumbers(str string) bool
- func ContainsSpecialCharacters(str string) bool
- func CreateDir(path string) error
- func CurrentDate() string
- func DecryptToken(token string, secret string) (*jwt.Token, error)
- func EncryptSha256(text string) string
- func ExistsDir(path string) bool
- func GenerateAuthToken(user *models.User, device *models.Device, secret string) (string, error)
- func GenerateOTP(length int) (string, error)
- func GenerateValidationCode(text string) (string, error)
- func GetProfilePicturePath(username string, path string) string
- func Int2String(num int) string
- func Int642String(num int64) string
- func IsEmpty(str string) bool
- func IsLowerCase(str string) bool
- func IsUpperCase(str string) bool
- func Ping() string
- func ReadFile(filepath string) ([]byte, error)
- func SaveFile(filepath string, content []byte) error
- func StringToObjectId(str string) (primitive.ObjectID, error)
- func ValidateDescription(description string) validateResult
- func ValidateEmail(email string) validateResult
- func ValidateName(name string) validateResult
- func ValidatePassword(password string) validateResult
- func ValueOrEmpty(str string) *string
Constants ¶
const DEFAULT_PROFILE_PICTURE_EXTENSION = ".jpg"
const MINIMUM_CHARACTERS_FOR_EMAIL = 5
const MINIMUM_CHARACTERS_FOR_PASSWORD = 16
const OTP_CHARS = "1234567890"
Variables ¶
This section is empty.
Functions ¶
func ContainsAny ¶
ContainsAny returns true if the string contains any of the chars
[param] str | string: string to check [param] chars | []string: chars to check
[return] bool: true if the string contains any of the chars
func ContainsNumbers ¶
ContainsNumbers returns true if the string contains any number
[param] str | string: string to check
[return] bool: true if the string contains any number
func ContainsSpecialCharacters ¶
ContainsSpecialCharacters returns true if the string contains any special character
[param] str | string: string to check
[return] bool: true if the string contains any special character
func CurrentDate ¶
func CurrentDate() string
func DecryptToken ¶
Decrypt a token
[param] token | string | The token
[return] *jwt.Token | The token --> error if something went wrong
func EncryptSha256 ¶
Encrypt a string using sha256
[param] text | string | The text to encrypt
[return] string | The encrypted text
func GenerateAuthToken ¶
Generate a new auth token
[param] user | models.User | The user [param] device | models.Device | The device
[return] string | The token --> error if something went wrong
func GenerateOTP ¶
Generate a random string
[param] length | int | The length of the string
[return] string | The random string --> error if something went wrong
func GenerateValidationCode ¶
Generate a validation code
[param] text | string | The text to encrypt
[return] string | The encrypted text
func GetProfilePicturePath ¶
func Int2String ¶
Convert int to string
[param] num | int: number to convert
[return] string: converted number
func Int642String ¶
Convert Int64 to String
[param] num | int64: number to convert
[return] string: converted number
func IsEmpty ¶
IsEmpty returns true if the string is empty
[param] str | string: string to check
[return] bool: true if the string is empty
func IsLowerCase ¶
IsLowerCase returns true if the string is lowercase
[param] str | string: string to check
[return] bool: true if the string is lowercase
func IsUpperCase ¶
IsUpperCase returns true if the string is uppercase
[param] str | string: string to check
[return] bool: true if the string is uppercase
func ReadFile ¶
ReadFile reads a file and returns its content
[param] filepath | string : path to the file [param] content | []byte : content of the file
[return] []byte : content of the file
func SaveFile ¶
ReadFile reads a file and returns its content
[param] filepath | string : path to the file [param] content | []byte : content of the file
[return] []byte : content of the file
func StringToObjectId ¶
StringToObjectId converts a string to a primitive.ObjectID
[param] str | string: string to convert
[return] primitive.ObjectID: converted string
func ValidateDescription ¶
func ValidateDescription(description string) validateResult
Check if the given description string is valid following the next rules:
[-] At least 8 characters [-] At most 500 characters [param] description : string: description to check [return] the description is valid or not
func ValidateEmail ¶
func ValidateEmail(email string) validateResult
Check if the given email is valid following the next rules:
[-] At least 5 characters [-] At least one @ [-] At least one . [param] email : string: email to check [return] the email is valid or not
func ValidateName ¶
func ValidateName(name string) validateResult
Check if the given name string is valid following the next rules:
[-] At least 2 characters [-] At most 50 characters [param] name : string: name to check [return] the name is valid or not
func ValidatePassword ¶
func ValidatePassword(password string) validateResult
Check if the given password is valid following the next rules:
[-] At least 16 characters [-] At least one special character [-] At least one number [param] password : string: password to check [return] the password is valid or not
func ValueOrEmpty ¶
Get string pointer from string or nil if empty
[param] str | string: string to convert
[return] *string: string pointer
Types ¶
This section is empty.