Documentation
¶
Index ¶
- Variables
- func ASCII(v string) bool
- func Alnum(v string, lang string) bool
- func Alpha(v string, lang string) bool
- func BIC(v string) bool
- func BTC(v string) bool
- func Base32(v string) bool
- func Base58(v string) bool
- func Base64(v string, urlsafe bool) bool
- func Binary(v string) bool
- func Bool(v string) bool
- func CIDR(v string) bool
- func CVV(v string) bool
- func Currency(v string, code string, opts *CurrencyOpts) bool
- func DataURI(v string) bool
- func Decimal(v string, locale string) bool
- func Digits(v string) bool
- func EAN(v string) bool
- func EIN(v string) bool
- func ETH(v string) bool
- func Email(v string) bool
- func FQDN(v string) bool
- func Float(v string) bool
- func HSL(v string) bool
- func Hash(v string, algo string) bool
- func Hex(v string) bool
- func HexColor(v string) bool
- func IBAN(v string) bool
- func IC(v string) bool
- func IMEI(v string) bool
- func IP(v string, ver int) bool
- func IPRange(v string) bool
- func ISBN(v string, ver int) bool
- func ISIN(v string) bool
- func ISO31661A(v string, num int) bool
- func ISO4217(v string) bool
- func ISO639(v string, num int) bool
- func ISRC(v string) bool
- func ISSN(v string, requireHyphen, caseSensitive bool) bool
- func In(v interface{}, list ...interface{}) bool
- func Int(v string) bool
- func JSON(v []byte) bool
- func JWT(v string) bool
- func LatLong(v string, dms bool) bool
- func Locale(v string) bool
- func LowerCase(v string) bool
- func MAC(v string, space int) bool
- func MD5(v string) bool
- func MIME(v string) bool
- func MagnetURI(v string) bool
- func Match(v string, re string) bool
- func MongoId(v string) bool
- func Numeric(v string) bool
- func Octal(v string) bool
- func PAN(v string) bool
- func PassportNumber(v string) bool
- func Phone(v string, cc string) bool
- func Port(v string) bool
- func RGB(v string) bool
- func RegisterRegexp(expr string)
- func SSN(v string) bool
- func SemVer(v string) bool
- func Slug(v string) bool
- func StrongPassword(v string, opts *StrongPasswordOpts) bool
- func URL(v string) bool
- func UUID(v string, ver int) bool
- func Uint(v string) bool
- func UpperCase(v string) bool
- func VAT(v string, cc string) bool
- func Zip(v string, cc string) bool
- type CurrencyOpts
- type StrongPasswordOpts
Constants ¶
This section is empty.
Variables ¶
var CurrencyOptsDefault = CurrencyOpts{ NeedSym: false, }
var StrongPasswordOptsDefault = StrongPasswordOpts{
MinLen: 8,
MinLower: 1,
MinUpper: 1,
MinNumbers: 1,
MinSymbols: 1,
}
Functions ¶
func ASCII ¶
ASCII reports whether or not v is an ASCII string.
isvalid:rule { "name": "ascii", "err": { "text": "must contain only ASCII characters" } }
func Alnum ¶
Alnum reports whether or not v is a valid alphanumeric string.
isvalid:rule { "name": "alnum", "opts": [[ { "key": null, "value": "en" } ]], "err": { "text": "must be an alphanumeric string" } }
func Alpha ¶
Alpha reports whether or not v is a valid alphabetic string.
isvalid:rule { "name": "alpha", "opts": [[ { "key": null, "value": "en" } ]], "err": { "text": "must be an alphabetic string" } }
func BIC ¶
BIC reports whether or not v represents a valid Bank Identification Code or SWIFT code.
isvalid:rule { "name": "bic", "err": { "text": "must be a valid BIC or SWIFT code" } }
func BTC ¶
BTC reports whether or not v represents a valid BTC address.
isvalid:rule { "name": "btc", "err": { "text": "must be a valid BTC address" } }
func Base32 ¶
Base32 reports whether or not v is a valid base32 string.
isvalid:rule { "name": "base32", "err": { "text": "must be a valid base32 string" } }
func Base58 ¶
Base58 reports whether or not v is a valid base58 string.
isvalid:rule { "name": "base58", "err": { "text": "must be a valid base58 string" } }
func Base64 ¶
Base64 reports whether or not v is a valid base64 string. NOTE: The standard "encoding/base64" package is used for validation. With urlsafe=false StdEncoding is used and with urlsafe=true RawURLEncoding is used.
isvalid:rule { "name": "base64", "opts": [[ { "key": null, "value": "false" }, { "key": "url", "value": "true" } ]], "err": { "text": "must be a valid base64 string" } }
func Binary ¶
Binary reports whether or not v represents a valid binary integer.
isvalid:rule { "name": "binary", "err": { "text": "string content must match a binary number" } }
func Bool ¶
Bool reports whether or not v represents a valid boolean. The following are considered valid boolean values: "true", "false", "TRUE", and "FALSE".
isvalid:rule { "name": "bool", "err": { "text": "string content must match a boolean value" } }
func CIDR ¶
CIDR reports whether or not v is a valid Classless Inter-Domain Routing notation. NOTE: CIDR uses "net".ParseCIDR to determine the validity of v.
isvalid:rule { "name": "cidr", "err": { "text": "must be a valid CIDR notation" } }
func CVV ¶
CVV reports whether or not v is a valid Card Verification Value.
isvalid:rule { "name": "cvv", "err": { "text": "must be a valid CVV" } }
func Currency ¶
func Currency(v string, code string, opts *CurrencyOpts) bool
Currency reports whether or not v represents a valid Currency amount.
isvalid:rule { "name": "ccy", "opts": [[ { "key": null, "value": "usd" } ], [ { "key": null, "value": "nil" } ]], "err": { "text": "must be a valid currency amount" } }
func DataURI ¶
DataURI reports whether or not v is a valid data URI.
isvalid:rule { "name": "datauri", "err": { "text": "must be a valid data URI" } }
func Decimal ¶
Decimal reports whether or not v represents a valid decimal number.
isvalid:rule { "name": "decimal", "opts": [[ { "key": null, "value": "en" } ]], "err": { "text": "string content must match a decimal number" } }
func Digits ¶
Digits reports whether or not v is a string of digits.
isvalid:rule { "name": "digits", "err": { "text": "must contain only digits" } }
func EAN ¶
EAN reports whether or not v is a valid European Article Number.
isvalid:rule { "name": "ean", "err": { "text": "must be a valid EAN" } }
func EIN ¶
EIN reports whether or not v is a valid Employer Identification Number.
isvalid:rule { "name": "ein", "err": { "text": "must be a valid EIN" } }
func ETH ¶
ETH reports whether or not v is a valid ethereum address.
isvalid:rule { "name": "eth", "err": { "text": "must be a valid ethereum address" } }
func Email ¶
Email reports whether or not v is a valid email address. NOTE: Email uses "net/mail".ParseAddress to determine the validity of v.
isvalid:rule { "name": "email", "err": { "text": "must be a valid email address" } }
func FQDN ¶
FQDN reports whether or not v is a valid Fully Qualified Domain Name. NOTE: FQDN TLD is required, numeric TLDs or trailing dots are disallowed, and underscores are forbidden.
isvalid:rule { "name": "fqdn", "err": { "text": "must be a valid FQDN" } }
func Float ¶
Float reports whether or not v represents a valid float.
isvalid:rule { "name": "float", "err": { "text": "string content must match a floating point number" } }
func HSL ¶
HSL reports whether or not v represents an HSL color value.
isvalid:rule { "name": "hsl", "err": { "text": "must be a valid HSL color" } }
func Hash ¶
Hash reports whether or not v is a hash of the specified algorithm.
isvalid:rule { "name": "hash", "err": { "text": "must be a valid hash" } }
func Hex ¶
Hex reports whether or not v is a valid hexadecimal string.
isvalid:rule { "name": "hex", "err": { "text": "must be a valid hexadecimal string" } }
func HexColor ¶
HexColor reports whether or not v is a valid hexadecimal color code.
isvalid:rule { "name": "hexcolor", "err": { "text": "must represent a valid hexadecimal color code" } }
func IBAN ¶
IBAN reports whether or not v is an International Bank Account Number.
isvalid:rule { "name": "iban", "err": { "text": "must be a valid IBAN" } }
func IC ¶
IC reports whether or not v is an Identity Card number.
isvalid:rule { "name": "ic", "err": { "text": "must be a valid identity card number" } }
func IMEI ¶
IMEI reports whether or not v is an IMEI number.
isvalid:rule { "name": "imei", "err": { "text": "must be a valid IMEI number" } }
func IP ¶
IP reports whether or not v is a valid IP address. The ver argument specifies the IP's expected version. The ver argument can be one of the following three values:
0 accepts both IPv4 and IPv6 4 accepts IPv4 only 6 accepts IPv6 only
---
isvalid:rule { "name": "ip", "opts": [[ { "key": null, "value": "0" }, { "key": "v4", "value": "4" }, { "key": "v6", "value": "6" } ]], "err": { "text": "must be a valid IP" } }
func IPRange ¶
IPRange reports whether or not v is a valid IP range (IPv4 only).
isvalid:rule { "name": "iprange", "err": { "text": "must be a valid IP range" } }
func ISBN ¶
ISBN reports whether or not v is a valid International Standard Book Number. The ver argument specifies the ISBN's expected version. The ver argument can be one of the following three values:
0 accepts both 10 and 13 10 accepts version 10 only 13 accepts version 13 only
---
isvalid:rule { "name": "isbn", "opts": [[ { "key": null, "value": "0" } ]], "err": { "text": "must be a valid ISBN" } }
func ISIN ¶
ISIN reports whether or not v is a valid International Securities Identification Number.
isvalid:rule { "name": "isin", "err": { "text": "must be a valid ISIN" } }
func ISO31661A ¶
ISO31661A reports whether or not v is a valid country code as defined by the ISO 3166-1 Alpha standard. The num argument specifies which of the two alpha sets of the standard should be tested. The num argument can be one of the following three values:
0 tests against both Alpha-2 and Alpha-3 2 tests against Alpha-2 only 3 tests against Alpha-3 only
---
isvalid:rule { "name": "iso31661a", "opts": [[ { "key": null, "value": "0" } ]], "err": { "text": "must be a valid ISO 3166-1 Alpha value" } }
func ISO4217 ¶
ISO4217 reports whether or not v is a valid currency code as defined by the ISO 4217 standard.
isvalid:rule { "name": "iso4217", "err": { "text": "must be a valid ISO 4217 value" } }
func ISO639 ¶
ISO639 reports whether or not v is a valid language code as defined by the ISO 639 set of standards. Currently only standards 639-1 & 639-2 are supported. The num argument specifies which of the supported standards should be tested. The num argument can be one of the following three values:
0 tests against both 639-1 & 639-2 1 tests against 639-1 only 2 tests against 639-2 only
---
isvalid:rule { "name": "iso369", "opts": [[ { "key": null, "value": "0" } ]], "err": { "text": "must be a valid ISO 639 value" } }
func ISRC ¶
ISRC reports whether or not v is a valid International Standard Recording Code.
isvalid:rule { "name": "isrc", "err": { "text": "must be a valid ISRC" } }
func ISSN ¶
ISSN reports whether or not v is a valid International Standard Serial Number.
isvalid:rule { "name": "issn", "err": { "text": "must be a valid ISSN" } }
func In ¶
func In(v interface{}, list ...interface{}) bool
In reports whether or not v is in the provided list.
isvalid:rule { "name": "in", "err": { "text": "must be in the list" } }
func Int ¶
Int reports whether or not v represents a valid integer.
isvalid:rule { "name": "int", "err": { "text": "string content must match an integer" } }
func JSON ¶
JSON reports whether or not v is a valid JSON value. NOTE: the input is validated using json.Unmarshal which accepts primitive values as long as they are JSON values.
isvalid:rule { "name": "json", "err": { "text": "must be a valid JSON" } }
func JWT ¶
JWT reports whether or not v is a valid JSON Web Token.
isvalid:rule { "name": "jwt", "err": { "text": "must be a valid JWT" } }
func LatLong ¶
LatLong reports whether or not v is a valid latitude-longitude coordinate string.
isvalid:rule { "name": "latlong", "opts": [[ { "key": null, "value": "false" }, { "key": "dms", "value": "true" } ]], "err": { "text": "must be a valid latitude-longitude coordinate" } }
func Locale ¶
Locale reports whether or not v is a valid locale.
isvalid:rule { "name": "locale", "err": { "text": "must be a valid locale" } }
func LowerCase ¶
LowerCase reports whether or not v is an all lower-case string.
isvalid:rule { "name": "lower", "err": { "text": "must contain only lower-case characters" } }
func MAC ¶
MAC reports whether or not v is a valid MAC address. The space argument specifies the identifier's expected address space (in bytes). The space argument can be one of the following three values:
0 accepts both EUI-48 and EUI-64 6 accepts EUI-48 format only 8 accepts EUI-64 format only
The allowed formatting of the identifiers is as follows:
// EUI-48 format "08:00:2b:01:02:03" "08-00-2b-01-02-03" "08002b010203" // EUI-64 format "08:00:2b:01:02:03:04:05" "08-00-2b-01-02-03-04-05" "08002b0102030405"
---
isvalid:rule { "name": "mac", "opts": [[ { "key": null, "value": "0" } ]], "err": { "text": "must be a valid MAC" } }
func MD5 ¶
MD5 reports whether or not v is a valid MD5 hash.
isvalid:rule { "name": "md5", "err": { "text": "must be a valid MD5 hash" } }
func MIME ¶
MIME reports whether or not v is of a valid MIME type format.
NOTE: This function only checks is the string format follows the etablished rules by the according RFC specifications. This function supports 'charset' in textual media types (https://tools.ietf.org/html/rfc6657).
This function does not check against all the media types listed by the IANA (https://www.iana.org/assignments/media-types/media-types.xhtml)
More informations in the RFC specifications:
- https://tools.ietf.org/html/rfc2045
- https://tools.ietf.org/html/rfc2046
- https://tools.ietf.org/html/rfc7231#section-3.1.1.1
- https://tools.ietf.org/html/rfc7231#section-3.1.1.5
---
isvalid:rule { "name": "mime", "err": { "text": "must be a valid media type" } }
func MagnetURI ¶
MagnetURI reports whether or not v is a valid magned URI.
isvalid:rule { "name": "magneturi", "err": { "text": "must be a valid magnet URI" } }
func Match ¶
Match reports whether or not v contains any match of the *registered* regular expression re. NOTE: re MUST be registered upfront with RegisterRegexp otherwise Match will return false even if v matches the regular expression.
isvalid:rule { "name": "re", "err": { "text": "must match the regular expression", "with_opts": true } }
func MongoId ¶
MongoId reports whether or not v is a valid hex-encoded representation of a MongoDB ObjectId.
isvalid:rule { "name": "mongoid", "err": { "text": "must be a valid Mongo Object Id" } }
func Numeric ¶
Numeric reports whether or not v is a valid numeric string.
isvalid:rule { "name": "numeric", "err": { "text": "string content must match a numeric value" } }
func Octal ¶
Octal reports whether or not v represents a valid octal integer.
isvalid:rule { "name": "octal", "err": { "text": "string content must match an octal number" } }
func PAN ¶
PAN reports whether or not v is a valid Primary Account Number or Credit Card number.
isvalid:rule { "name": "pan", "err": { "text": "must be a valid PAN" } }
func PassportNumber ¶
PassportNumber reports whether or not v is a valid passport number.
isvalid:rule { "name": "passport", "err": { "text": "must be a valid passport number" } }
func Phone ¶
Phone reports whether or not v is a valid phone number in the country identified by the given country code cc.
isvalid:rule { "name": "phone", "opts": [[ { "key": null, "value": "us" } ]], "err": { "text": "must be a valid phone number" } }
func Port ¶
Port reports whether or not v is a valid port number.
isvalid:rule { "name": "port", "err": { "text": "must be a valid port number" } }
func RGB ¶
RGB reports whether or not v is a valid RGB color.
isvalid:rule { "name": "rgb", "err": { "text": "must be a valid RGB color" } }
func RegisterRegexp ¶
func RegisterRegexp(expr string)
RegisterRegexp compiles the given expression and caches the result. The given expr is assumed to be a valid regular expression, if it's not then RegisterRegexp will panic.
func SSN ¶
SSN reports whether or not v has a valid Social Security Number format.
isvalid:rule { "name": "ssn", "err": { "text": "must be a valid SSN" } }
func SemVer ¶
SemVer reports whether or not v is a valid Semantic Versioning number. For reference: https://semver.org/
isvalid:rule { "name": "semver", "err": { "text": "must be a valid semver number" } }
func Slug ¶
Slug reports whether or not v is a valid slug.
isvalid:rule { "name": "slug", "err": { "text": "must be a valid slug" } }
func StrongPassword ¶
func StrongPassword(v string, opts *StrongPasswordOpts) bool
StrongPassword reports whether or not v is a strong password.
isvalid:rule { "name": "strongpass", "opts": [[ { "key": null, "value": "nil" } ]], "err": { "text": "must be a strong password" } }
func URL ¶
URL reports whether or not v is a valid Uniform Resource Locator.
isvalid:rule { "name": "url", "err": { "text": "must be a valid URL" } }
func UUID ¶
UUID reports whether or not v is a valid Universally Unique IDentifier. NOTE: only versions 3, 4, and 5 are currently supported.
isvalid:rule { "name": "uuid", "opts": [[ { "key": null, "value": "4" } ]], "err": { "text": "must be a valid UUID" } }
func Uint ¶
Uint reports whether or not v represents a valid unsigned integer.
isvalid:rule { "name": "uint", "err": { "text": "string content must match an unsigned integer" } }
func UpperCase ¶
UpperCase reports whether or not v is an all upper-case string.
isvalid:rule { "name": "upper", "err": { "text": "must contain only upper-case characters" } }
Types ¶
type CurrencyOpts ¶
type CurrencyOpts struct {
NeedSym bool
}
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
isvalid
command
isvalid is a tool for generating struct field validation.
|
isvalid is a tool for generating struct field validation. |
internal
|
|
cldr/gen
command
|
|
search
package search is used to find targets for the generator.
|
package search is used to find targets for the generator. |
l10n
|
|