utils

package
Version: v0.0.0-...-0db321b Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ValidationErrors is a list that contains all validation errors
	ValidationErrors = []error{ErrInvalidID, ErrInvalidURL}
	// ErrInvalidID respresents an invalid tiny URL id error
	ErrInvalidID = errors.New("ID contains illegal characters")
	// ErrInvalidURL respresents an invalid tiny URL url error
	ErrInvalidURL = errors.New("invalid URL")
)

Functions

func GenerateID

func GenerateID(length int) string

GenerateID returns a random base64URL string of provided length Not guaranteed to be unique

func IsValidationError

func IsValidationError(err error) bool

IsValidationError returns true if provided error is a validation error

func ValidateID

func ValidateID(id string) error

ValidateID validates a tiny URL ID

func ValidateURL

func ValidateURL(urlStr string) error

ValidateURL validates provided URL

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL