utils

package
v0.0.0-...-68e8b16 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsAlphabeticCharacters

func ContainsAlphabeticCharacters(s string) bool

ContainsAlphabeticCharacters returns true if the provided string 's' alphabetic numbers.

func ContainsNoneAlphabeticCharacters

func ContainsNoneAlphabeticCharacters(s string) bool

ContainsNoneAlphabeticCharacters returns true if the provided string 's' contains anything other than alphabetic characters.

func ContainsNumbericCharacters

func ContainsNumbericCharacters(s string) bool

ContainsNumbericCharacters returns true if the provided string 's' contains numbers.

func ContainsWhitespace

func ContainsWhitespace(s string) bool

ContainsWhitespace returns true if the provided string 's' contains any whitespace characters.

func DoesPasswordMatch

func DoesPasswordMatch(password, hashedPassword string) bool

compares a hashed password with its plaintext version using bcrypt algorithm.

func HashPassword

func HashPassword(plainText string) (*string, error)

hashes plaintext password using bcrypt algorithm

func IsAlphaNumeric

func IsAlphaNumeric(s string) bool

IsAlphaNumeric returns true if the provided string 's' contains both alphabetic and numberal characters.

func IsEmail

func IsEmail(email string) bool

IsEmail returns true if the provided 'email' contains only the address part of a valid RFC 5322 address.

func ReadJson

func ReadJson(w http.ResponseWriter, r *http.Request, dest interface{}) error

reads json body into 'dest' make sure the `dest` is never nil otherwise it will panic

func StringLengthInBounds

func StringLengthInBounds(s string, min, max int) bool

StringLengthInBounds returns true of the provided string 's' is greater than or equal to min and less than or equal to max.

func WriteErrorJsonResponse

func WriteErrorJsonResponse(w http.ResponseWriter, errorCode string, statusCode int, messages interface{})

func WriteInternalErrorJsonResponse

func WriteInternalErrorJsonResponse(w http.ResponseWriter)

func WriteRequestPayloadError

func WriteRequestPayloadError(err error, w http.ResponseWriter)

handles common json parsing errors and writes error response

func WriteSuccessJsonResponse

func WriteSuccessJsonResponse(w http.ResponseWriter, statusCode int, data interface{})

Types

type ServerResponse

type ServerResponse struct {
	Success  bool        `json:"success"`
	Code     string      `json:"code,omitempty"`
	Messages interface{} `json:"messages,omitempty"`
	Data     interface{} `json:"data,omitempty"`
}

type Validatable

type Validatable interface {
	Validate() []string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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