is

package
v0.0.0-...-e4caca2 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Unknown is unresolved OS type
	Unknown = iota
	// Win is Windows type
	Win
	// Unix is *nix OS types
	Unix
)

Used by IsFilePath func

Variables

View Source
var ISO3166List = []ISO3166Entry{}/* 249 elements not displayed */

ISO3166List based on https://www.iso.org/obp/ui/#search/code/ Code Type "Officially Assigned Codes"

Functions

func ASCII

func ASCII(s string) bool

ASCII check if the string contains ASCII chars only. Empty string is valid.

func Alpha

func Alpha(s string) bool

Alpha check if the string contains only letters (a-zA-Z). Empty string is valid.

func Alphanumeric

func Alphanumeric(s string) bool

Alphanumeric check if the string contains only letters and numbers. Empty string is valid.

func Base64

func Base64(s string) bool

Base64 check if a string is base64 encoded.

func ByteLength

func ByteLength(str string, min, max int) bool

ByteLength check if the string's length (in bytes) falls in a range.

func CreditCard

func CreditCard(str string) bool

CreditCard check if the string is a credit card.

func DNSName

func DNSName(str string) bool

DNSName will validate the given string as a DNS name

func DataURI

func DataURI(str string) bool

DataURI checks if a string is base64 encoded data URI such as an image

func DialString

func DialString(str string) bool

DialString validates the given string for usage with the various Dial() functions

func Email

func Email(s string) bool

Email is a constraint to do a simple validation for email addresses, it only check if the string contains "@" and that it is not in the first or last character of the string https://en.wikipedia.org/wiki/Email_address#Valid_email_addresses

func Exists

func Exists(path string) (bool, error)

Exists returns whether the given file or directory exists or not

func FilePath

func FilePath(str string) (bool, int)

FilePath check is a string is Win or Unix file path and returns it's type.

func Float

func Float(str string) bool

Float check if the string is a float.

func FullWidth

func FullWidth(str string) bool

FullWidth check if the string contains any full-width chars. Empty string is valid.

func HalfWidth

func HalfWidth(str string) bool

HalfWidth check if the string contains any half-width chars. Empty string is valid.

func Hexadecimal

func Hexadecimal(str string) bool

Hexadecimal check if the string is a hexadecimal number.

func Hexcolor

func Hexcolor(str string) bool

Hexcolor check if the string is a hexadecimal color.

func IP

func IP(str string) bool

IP checks if a string is either IP version 4 or 6.

func IPv4

func IPv4(str string) bool

IPv4 check if the string is an IP version 4.

func IPv6

func IPv6(str string) bool

IPv6 check if the string is an IP version 6.

func ISBN

func ISBN(str string, version int) bool

ISBN 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 ISBN10

func ISBN10(str string) bool

ISBN10 check if the string is an ISBN version 10.

func ISBN13

func ISBN13(str string) bool

ISBN13 check if the string is an ISBN version 13.

func ISO3166Alpha2

func ISO3166Alpha2(str string) bool

ISO3166Alpha2 checks if a string is valid two-letter country code

func ISO3166Alpha3

func ISO3166Alpha3(str string) bool

ISO3166Alpha3 checks if a string is valid three-letter country code

func InRange

func InRange(value, left, right float64) bool

InRange returns true if value lies between left and right border

func Int

func Int(str string) bool

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

func JSON

func JSON(str string) bool

JSON check if the string is valid JSON (note: uses json.Unmarshal).

func Latitude

func Latitude(str string) bool

Latitude check if a string is valid latitude.

func Longitude

func Longitude(str string) bool

Longitude check if a string is valid longitude.

func LowerCase

func LowerCase(str string) bool

LowerCase check if the string is lowercase. Empty string is valid.

func MAC

func MAC(str string) bool

MAC 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 MongoID

func MongoID(str string) bool

MongoID check if the string is a valid hex-encoded representation of a MongoDB ObjectId.

func Multibyte

func Multibyte(s string) bool

Multibyte check if the string contains one or more multibyte chars. Empty string is valid.

func Natural

func Natural(value float64) bool

Natural returns true if value is natural number (positive and whole)

func Numeric

func Numeric(s string) bool

Numeric check if the string contains only numbers. Empty string is valid.

func Port

func Port(str string) bool

Port checks if a string represents a valid port

func PrintableASCII

func PrintableASCII(s string) bool

PrintableASCII check if the string contains printable ASCII chars only. Empty string is valid.

func RGBcolor

func RGBcolor(str string) bool

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

func RequestURI

func RequestURI(rawurl string) bool

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

func RequestURL

func RequestURL(rawurl string) bool

RequestURL check if the string rawurl, assuming it was received in an HTTP request, is a valid URL confirm to RFC 3986

func SSN

func SSN(str string) bool

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

func Semver

func Semver(str string) bool

Semver check if string is valid semantic version

func StringLength

func StringLength(str string, min int, max int) bool

StringLength check string's length (including multi byte strings)

func URL

func URL(str string) bool

URL check if the string is an URL.

func UTFDigit

func UTFDigit(s string) bool

UTFDigit check if the string contains only unicode radix-10 decimal digits. Empty string is valid.

func UTFLetter

func UTFLetter(str string) bool

UTFLetter check if the string contains only unicode letter characters. Similar to IsAlpha but for all languages. Empty string is valid.

func UTFLetterNumeric

func UTFLetterNumeric(s string) bool

UTFLetterNumeric check if the string contains only unicode letters and numbers. Empty string is valid.

func UTFNumeric

func UTFNumeric(s string) bool

UTFNumeric check if the string contains only unicode numbers of any kind. Numbers can be 0-9 but also Fractions ¾,Roman Ⅸ and Hangzhou 〩. Empty string is valid.

func UUID

func UUID(str string) bool

UUID check if the string is a UUID (version 3, 4 or 5).

func UUIDv3

func UUIDv3(str string) bool

UUIDv3 check if the string is a UUID version 3.

func UUIDv4

func UUIDv4(str string) bool

UUIDv4 check if the string is a UUID version 4.

func UUIDv5

func UUIDv5(str string) bool

UUIDv5 check if the string is a UUID version 5.

func UpperCase

func UpperCase(str string) bool

UpperCase check if the string is uppercase. Empty string is valid.

func VariableWidth

func VariableWidth(str string) bool

VariableWidth check if the string contains a mixture of full and half-width chars. Empty string is valid.

func Whole

func Whole(value float64) bool

Whole returns true if value is whole number

Types

type ISO3166Entry

type ISO3166Entry struct {
	EnglishShortName string
	FrenchShortName  string
	Alpha2Code       string
	Alpha3Code       string
	Numeric          string
}

ISO3166Entry stores country codes

Jump to

Keyboard shortcuts

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