utils

package
v0.0.0-...-c846bbc Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Default charset to be used with StringWithCharset function
	DefaultCharset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
	SpecialCharset = "!@#$%&*+-_"
	// Password charset adds special chars
	PasswordCharset = DefaultCharset + SpecialCharset
)

Variables

This section is empty.

Functions

func StringWithCharset

func StringWithCharset(length int, charset string) (string, error)

Generates a random string with the charset infromed and the length

func TruncateString

func TruncateString(str string, borderSizeToKeep int) string

func ValidateEmail

func ValidateEmail(email string) error

Types

type PasswordValidator

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

func GetPasswordValidatorInstance

func GetPasswordValidatorInstance() (*PasswordValidator, error)

GetPasswordValidatorInstance (1) retrieves the reference for a global PasswordValidator instance if it already exists or (2) creates a new one, assigns it to the aforementioned global reference, and returns it.

func (*PasswordValidator) ValidatePassword

func (pv *PasswordValidator) ValidatePassword(input string) error

ValidatePassword returns an error if the password does not meet the requirements.

type ValidatePasswordError

type ValidatePasswordError struct {
	Err                  error
	FailedValidationsMap map[string]string
}

ValidatePasswordError is an error type that contains the failed validations specified under a map.

func (*ValidatePasswordError) Error

func (e *ValidatePasswordError) Error() string

func (*ValidatePasswordError) FailedValidations

func (e *ValidatePasswordError) FailedValidations() map[string]string

func (*ValidatePasswordError) Unwrap

func (e *ValidatePasswordError) Unwrap() error

Jump to

Keyboard shortcuts

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