validate

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: May 12, 2022 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisplayName

func DisplayName(displayName string) error

DisplayName checks that a requested display name is valid

func Email

func Email(email string) error

Email makes sure that a given email address is a valid address. Returns an error if not.

func EmojiShortcode

func EmojiShortcode(shortcode string) error

EmojiShortcode just runs the given shortcode through the regular expression for emoji shortcodes, to figure out whether it's a valid shortcode, ie., 2-30 characters, lowercase a-z, numbers, and underscores.

func Language

func Language(lang string) error

Language checks that the given language string is a 2- or 3-letter ISO 639 code. Returns an error if the language cannot be parsed. See: https://pkg.go.dev/golang.org/x/text/language

func NewPassword

func NewPassword(password string) error

NewPassword returns an error if the given password is not sufficiently strong, or nil if it's ok.

func Note

func Note(note string) error

Note checks that a given profile/account note/bio is valid

func Privacy

func Privacy(privacy string) error

Privacy checks that the desired privacy setting is valid

func SignUpReason

func SignUpReason(reason string, reasonRequired bool) error

SignUpReason checks that a sufficient reason is given for a server signup request

func SiteDescription

func SiteDescription(d string) error

SiteDescription ensures that the given site description is within spec.

func SiteShortDescription

func SiteShortDescription(d string) error

SiteShortDescription ensures that the given site short description is within spec.

func SiteTerms

func SiteTerms(t string) error

SiteTerms ensures that the given site terms string is within spec.

func SiteTitle

func SiteTitle(siteTitle string) error

SiteTitle ensures that the given site title is within spec.

func Struct

func Struct(s interface{}) error

Struct validates the passed struct, returning validator.ValidationErrors if invalid, or nil if OK.

func ULID

func ULID(i string) bool

ULID returns true if the passed string is a valid ULID.

func Username

func Username(username string) error

Username makes sure that a given username is valid (ie., letters, numbers, underscores, check length). Returns an error if not.

Types

This section is empty.

Jump to

Keyboard shortcuts

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