validate

package
v0.0.53 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EmailRegex string = `^[a-z0-9._%+\-]+@[a-z0-9.\-]+\.[a-z]{2,7}$`
	EmailMax   int    = 254
	EmailMin   int    = 6 // min length is 3, tho domain rules make them longer: 6

	NameMin   int    = 1
	NameMax   int    = 32
	NameRegex string = `^[\p{L}\p{M}'\-\s]+$`

	PasswordMin         int    = 16
	PasswordMax         int    = 64
	UpperCase           string = `[A-Z]`
	LowerCase           string = `[a-z]`
	Number              string = `[0-9]`
	SpecialChar         string = `[\@\!\#\$\%\^\&\*\(\)\_\+\{\}\:\;\"\'<>\,\.\?\/\|\\\=\-\[\]\~]`
	KeyboardSequenceMax int    = 5
	RepeatCharMax       int    = 4 // allowing 4 for true randomness and ggGg scenarios

	UuidPattern string = `^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$`

	ServiceNameMin   int    = 2
	ServiceNameMax   int    = 32
	ServiceNameRegex string = `^[a-z0-9_-]+$`
)

Variables

View Source
var KeyboardSequences = []string{"`1234567890-=", `~!@#$\%^&*()_+`, "qwertyuiop[]\\", "qwertyuiop{}|", "asdfghjkl;'", "asdfghjkl:\"", "zxcvbnm,./", "zxcvbnm<>?", "1qaz2wsx3edc4rfv5tgb6yhn7ujm8ik,9ol.0p;/-['=]", "!qaz@wsx#edc$rfv%tgb^yhn&ujm*ik,(ol.)p:?_{\"+}", "=[;.-pl,0okm9ijn8uhb7ygv6tfc5rdx4esz3wa2q1]", `}"?+{:>_pl<)okm(ijn*uhb&ygv^tfc\%rdx$esz#wa@q!`, "abcdefghijklmnopqrstuvwxyz"}

includes alphabet

Functions

func ContainsKeyboardSequence

func ContainsKeyboardSequence(password string) error

func IsKeyboardSequence

func IsKeyboardSequence(password, sequence string) bool

includes reverse of any sequence

func IsValidBirthday added in v0.0.15

func IsValidBirthday(dob string) error

does not handle empty string, aka a required field, only checks format

func IsValidEmail added in v0.0.15

func IsValidEmail(email string) error

func IsValidName added in v0.0.15

func IsValidName(name string) error

func IsValidPassword added in v0.0.15

func IsValidPassword(password string) error

func IsValidServiceName added in v0.0.40

func IsValidServiceName(service string) bool

func IsValidUuid

func IsValidUuid(uuid string) bool

func MatchesRegex

func MatchesRegex(s, pattern string) bool

func RepeatChar

func RepeatChar(password string) error

func TooLong

func TooLong(field interface{}, max int) bool

func TooShort

func TooShort(field interface{}, min int) bool

Types

This section is empty.

Jump to

Keyboard shortcuts

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