govalidator

package
v0.0.0-...-2c72e55 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: Apache-2.0, MIT Imports: 7 Imported by: 0

Documentation

Overview

Package govalidator is package of validators and sanitizers for strings, structs and collections.

Index

Constants

View Source
const (
	CreditCard string = "" /* 151-byte string literal not displayed */
	ISBN10     string = "^(?:[0-9]{9}X|[0-9]{10})$"
	ISBN13     string = "^(?:[0-9]{13})$"
	Hexcolor   string = "^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$"
	RGBcolor   string = "" /* 157-byte string literal not displayed */
	Base64     string = "^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=|[A-Za-z0-9+\\/]{4})$"
	SSN        string = `^\d{3}[- ]?\d{2}[- ]?\d{4}$`
	Int        string = "^(?:[-+]?(?:0|[1-9][0-9]*))$"
)

Basic regular expressions for validating strings

Variables

This section is empty.

Functions

func IsBase64

func IsBase64(str string) bool

IsBase64 check if a string is base64 encoded.

func IsCreditCard

func IsCreditCard(str string) bool

IsCreditCard check if the string is a credit card.

func IsHexcolor

func IsHexcolor(str string) bool

IsHexcolor check if the string is a hexadecimal color.

func IsIPv6

func IsIPv6(str string) bool

IsIPv6 check if the string is an IP version 6.

func IsISBN

func IsISBN(str string, version int) bool

IsISBN check if the string is an ISBN (version 10 or 13). If version value is not equal to 10 or 13, it will be check both variants.

func IsISBN10

func IsISBN10(str string) bool

IsISBN10 check if the string is an ISBN version 10.

func IsISBN13

func IsISBN13(str string) bool

IsISBN13 check if the string is an ISBN version 13.

func IsInt

func IsInt(str string) bool

IsInt check if the string is an integer. Empty string is valid.

func IsMAC

func IsMAC(str string) bool

IsMAC check if a string is valid MAC address. Possible MAC formats: 01:23:45:67:89:ab 01:23:45:67:89:ab:cd:ef 01-23-45-67-89-ab 01-23-45-67-89-ab-cd-ef 0123.4567.89ab 0123.4567.89ab.cdef

func IsNull

func IsNull(str string) bool

IsNull check if the string is null.

func IsRGBcolor

func IsRGBcolor(str string) bool

IsRGBcolor check if the string is a valid RGB color in form rgb(RRR, GGG, BBB).

func IsRequestURI

func IsRequestURI(rawurl string) bool

IsRequestURI check if the string rawurl, assuming it was received in an HTTP request, is an absolute URI or an absolute path.

func IsSSN

func IsSSN(str string) bool

IsSSN will validate the given string as a U.S. Social Security Number

func ToInt

func ToInt(value interface{}) (res int64, err error)

ToInt convert the input string or any int type to an integer type 64, or 0 if the input is not an integer.

Types

This section is empty.

Jump to

Keyboard shortcuts

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