utils

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2021 License: MIT Imports: 22 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckEmptyString

func CheckEmptyString(text string) (*string, error)

CheckEmptyString check that the string isn't empty

func CheckIdentifierExists

func CheckIdentifierExists(profile *profileutils.UserProfile, UID string) bool

CheckIdentifierExists check if an identifier exists

func CheckUserHasPermission added in v0.0.2

func CheckUserHasPermission(roles []profileutils.Role, permission profileutils.Permission) bool

CheckUserHasPermission takes in the user roles and a permission and verifies that the user has required permissions

func FindItem

func FindItem(slice []string, value string) (int, bool)

FindItem is a linear search implementation that checks if a string is contained in a slice and returns its index and a boolean The index can be used for slicing out an item from a slice.

func GetRandomName

func GetRandomName() *string

GetRandomName generates a random name from the list of adjectives and surnames in this package formatted as "adjective_surname". For example '@focused_turing23254'. If retry is non-zero, a random integer between 0 and 10 will be added to the end of the name, e.g `focused_turing3`

func GetUserNavigationActions added in v0.0.2

func GetUserNavigationActions(
	ctx context.Context,
	user profileutils.UserProfile,
	roles []profileutils.Role,
) (*dto.GroupedNavigationActions, error)

GetUserNavigationActions returns a sorted primary and secondary user navigation actions

func GetUserPermissions added in v0.0.2

func GetUserPermissions(roles []profileutils.Role) []string

GetUserPermissions returns all the scopes of user permissions

func GetUserResponse

func GetUserResponse(text string) string

GetUserResponse gets the concatenated text from Africans Talking and splits it to get the current user input

func GroupNested added in v0.0.2

func GroupNested(
	actions []domain.NavigationAction,
) []domain.NavigationAction

GroupNested groups navigation actions into parents and children

func GroupPriority added in v0.0.2

func GroupPriority(
	actions []domain.NavigationAction,
) (primary, secondary []domain.NavigationAction)

GroupPriority groups navigation actions into primary and secondary actions

func IfCoverExistsInSlice

func IfCoverExistsInSlice(srcCovers []profileutils.Cover, cover profileutils.Cover) bool

IfCoverExistsInSlice checks is a cover is in a slice. In a slice of covers of a given length (srcCovers), the cover is question will only match one if it does exist in the srcCovers. Hence; - if the difference between `coversThatExists` and `coversThatDontExist` is less than 0, it means the cover is question does not exist in srcCovers . - if the difference between `coversThatExists` and `coversThatDontExist` is equal than 0, it means the cover is question does exist in srcCovers.

func IsFavNavAction added in v0.0.2

func IsFavNavAction(u *profileutils.UserProfile, title string) bool

IsFavNavAction checks if user has book marked the provided navaction

func IsLetter

func IsLetter(s string) bool

IsLetter ...

func MatchAndReturn

func MatchAndReturn(old bool, new bool) bool

MatchAndReturn checks is the new is not equal to old and returns it. Otherwise the old used when setting communication settings

func NewActionsMapper added in v0.0.2

NewActionsMapper maps the new navigation actions mapper to the old navigation actions implementation It is meant to be used as a transition and ease changes made without affecting the frontend

func NewInterServiceClient

func NewInterServiceClient(serviceName string, baseExt extension.BaseExtension) *interserviceclient.InterServiceClient

NewInterServiceClient initializes an external service in the correct environment given its name

func RecordSpanError

func RecordSpanError(span trace.Span, err error)

RecordSpanError is a helper function to capture errors in a span

func RemoveDuplicateStrings added in v0.0.2

func RemoveDuplicateStrings(strings []string) []string

RemoveDuplicateStrings removes duplicate strings from a list of strings

func ServiceHealthEndPoint

func ServiceHealthEndPoint(input string) (string, error)

ServiceHealthEndPoint creates a url to the service health endpoint

func UniquePermissionsArray

func UniquePermissionsArray(arr []profileutils.PermissionType) []profileutils.PermissionType

UniquePermissionsArray removes duplicate permissions in an array of permissions

func ValidateDateDigits

func ValidateDateDigits(pin string) error

ValidateDateDigits validates user pin to ensure a PIN only contains digits

func ValidateDateLength

func ValidateDateLength(date string) error

ValidateDateLength ensures that the dates are of only 8 numbers

func ValidatePIN

func ValidatePIN(pin string) error

ValidatePIN ...

func ValidatePINLength

func ValidatePINLength(pin string) error

ValidatePINLength ...

func ValidateSignUpInput

func ValidateSignUpInput(input *dto.SignUpInput) (*dto.SignUpInput, error)

ValidateSignUpInput returns a valid sign up input

func ValidateUID

func ValidateUID(w http.ResponseWriter, r *http.Request) (*dto.UIDPayload, error)

ValidateUID checks that the uid supplied in the indicated request is valid

func ValidateYearOfBirth

func ValidateYearOfBirth(date string) string

ValidateYearOfBirth validates that the year enter is 18 years and above

Types

This section is empty.

Jump to

Keyboard shortcuts

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