Documentation ¶
Overview ¶
These code is copied from https://github.com/asaskevich/govalidator See the license https://github.com/asaskevich/govalidator/blob/master/LICENSE
Index ¶
- Constants
- func AddValidator(name string, f func(v string) error) error
- func ValidateBoolean(value string) error
- func ValidateDialString(value string) error
- func ValidateNetAddr(value string) error
- func ValidateNonempty(value string) error
- func ValidateNumeric(value string) error
- func ValidatePath(value string) error
- func ValidatePrintableASCII(value string) error
- func ValidateURL(value string) error
- type Rule
- type Validator
- type ValidatorFunc
Constants ¶
View Source
const ( Email string = "" /* 1212-byte string literal not displayed */ CreditCard string = "" /* 151-byte string literal not displayed */ ISBN10 string = "^(?:[0-9]{9}X|[0-9]{10})$" ISBN13 string = "^(?:[0-9]{13})$" UUID3 string = "^[0-9a-f]{8}-[0-9a-f]{4}-3[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}$" UUID4 string = "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$" UUID5 string = "^[0-9a-f]{8}-[0-9a-f]{4}-5[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$" UUID string = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" Alpha string = "^[a-zA-Z]+$" Alphanumeric string = "^[a-zA-Z0-9]+$" Numeric string = "^[-+]?[0-9]+$" Int string = "^(?:[-+]?(?:0|[1-9][0-9]*))$" Float string = "^(?:[-+]?(?:[0-9]+))?(?:\\.[0-9]*)?(?:[eE][\\+\\-]?(?:[0-9]+))?$" Hexadecimal string = "^[0-9a-fA-F]+$" Hexcolor string = "^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$" RGBcolor string = "" /* 157-byte string literal not displayed */ ASCII string = "^[\x00-\x7F]+$" Multibyte string = "[^\x00-\x7F]" FullWidth string = "[^\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]" HalfWidth string = "[\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]" Base64 string = "^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=|[A-Za-z0-9+\\/]{4})$" PrintableASCII string = "^[\x20-\x7E]+$" DataURI string = "^data:.+\\/(.+);base64$" Latitude string = "^[-+]?([1-8]?\\d(\\.\\d+)?|90(\\.0+)?)$" Longitude string = "^[-+]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)$" DNSName string = `^([a-zA-Z0-9]{1}[a-zA-Z0-9_-]{1,62}){1}(\.[a-zA-Z0-9]{1}[a-zA-Z0-9_-]{1,62})*$` URL string = `` /* 331-byte string literal not displayed */ SSN string = `^\d{3}[- ]?\d{2}[- ]?\d{4}$` WinPath string = `^[a-zA-Z]:\\(?:[^\\/:*?"<>|\r\n]+\\)*[^\\/:*?"<>|\r\n]*$` UnixPath string = `^((?:\.{0,2})?(?:[a-zA-Z0-9]+\.?[a-zA-Z0-9]+)?(?:\/[a-zA-Z0-9\.\:]*(?:_[a-zA-Z0-9\:\.]+)*(?:\-[\:a-zA-Z0-9\.]+)*)*\/?)$` Semver string = "" /* 183-byte string literal not displayed */ )
Basic regular expressions for validating strings
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 ¶
This section is empty.
Functions ¶
func ValidateBoolean ¶
func ValidateDialString ¶
func ValidateNetAddr ¶
func ValidateNonempty ¶
func ValidateNumeric ¶
func ValidatePath ¶
func ValidatePrintableASCII ¶
func ValidateURL ¶
A URL represents a parsed URL (technically, a URI reference). The general form represented is: scheme://[userinfo@]host/path[?query][#fragment]
Types ¶
Click to show internal directories.
Click to hide internal directories.