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 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 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 any, list ...any) 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, expr string) bool
- func MongoId(v string) bool
- func Numeric(v string) bool
- func Octal(v string) bool
- func PAN(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 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.
valid:rule.yaml
name: ascii error: { text: "must contain only ASCII characters" }
func Alnum ¶
Alnum reports whether or not v is a valid alphanumeric string.
valid:rule.yaml
name: alnum args: [{ default: en }] error: { text: "must be an alphanumeric string" }
func Alpha ¶
Alpha reports whether or not v is a valid alphabetic string.
valid:rule.yaml
name: alpha args: [{ default: en }] error: { text: "must be an alphabetic string" }
func BIC ¶
BIC reports whether or not v represents a valid Bank Identification Code or SWIFT code.
valid:rule.yaml
name: bic error: { text: "must be a valid BIC or SWIFT code" }
func BTC ¶
BTC reports whether or not v represents a valid BTC address.
valid:rule.yaml
name: btc error: { text: "must be a valid BTC address" }
func Base32 ¶
Base32 reports whether or not v is a valid base32 string.
valid:rule.yaml
name: base32 error: { text: "must be a valid base32 string" }
func Base58 ¶
Base58 reports whether or not v is a valid base58 string.
valid:rule.yaml
name: base58 error: { 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.
valid:rule.yaml
name: base64 args: - default: false options: [{ value: true, alias: url }] error: { text: "must be a valid base64 string" }
func Binary ¶
Binary reports whether or not v represents a valid binary integer.
valid:rule.yaml
name: binary error: { 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".
valid:rule.yaml
name: bool error: { 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.
valid:rule.yaml
name: cidr error: { text: "must be a valid CIDR notation" }
func CVV ¶
CVV reports whether or not v is a valid Card Verification Value.
valid:rule.yaml
name: cvv error: { 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.
valid:rule.yaml
name: ccy args: - default: usd - default: null error: { text: "must be a valid currency amount" }
func DataURI ¶
DataURI reports whether or not v is a valid data URI.
valid:rule.yaml
name: datauri error: { text: "must be a valid data URI" }
func Decimal ¶
Decimal reports whether or not v represents a valid decimal number.
valid:rule.yaml
name: decimal args: [{ default: en }] error: { text: "string content must match a decimal number" }
func Digits ¶
Digits reports whether or not v is a string of digits.
valid:rule.yaml
name: digits error: { text: "must contain only digits" }
func EAN ¶
EAN reports whether or not v is a valid European Article Number.
valid:rule.yaml
name: ean error: { text: "must be a valid EAN" }
func ETH ¶
ETH reports whether or not v is a valid ethereum address.
valid:rule.yaml
name: eth error: { 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.
valid:rule.yaml
name: email error: { 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.
valid:rule.yaml
name: fqdn error: { text: "must be a valid FQDN" }
func Float ¶
Float reports whether or not v represents a valid float.
valid:rule.yaml
name: float error: { text: "string content must match a floating point number" }
func HSL ¶
HSL reports whether or not v represents an HSL color value.
valid:rule.yaml
name: hsl error: { text: "must be a valid HSL color" }
func Hash ¶
Hash reports whether or not v is a hash of the specified algorithm.
valid:rule.yaml
name: hash error: { text: "must be a valid hash" }
func Hex ¶
Hex reports whether or not v is a valid hexadecimal string.
valid:rule.yaml
name: hex error: { text: "must be a valid hexadecimal string" }
func HexColor ¶
HexColor reports whether or not v is a valid hexadecimal color code.
valid:rule.yaml
name: hexcolor error: { text: "must represent a valid hexadecimal color code" }
func IBAN ¶
IBAN reports whether or not v is an International Bank Account Number.
valid:rule.yaml
name: iban error: { text: "must be a valid IBAN" }
func IMEI ¶
IMEI reports whether or not v is an IMEI number.
valid:rule.yaml
name: imei error: { 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
---
valid:rule.yaml
name: ip args: - default: 0 options: - { value: 4, alias: v4 } - { value: 6, alias: v6 } error: { text: "must be a valid IP" }
func IPRange ¶
IPRange reports whether or not v is a valid IP range (IPv4 only).
valid:rule.yaml
name: iprange error: { 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
---
valid:rule.yaml
name: isbn args: [{ default: 0 }] error: { text: "must be a valid ISBN" }
func ISIN ¶
ISIN reports whether or not v is a valid International Securities Identification Number.
valid:rule.yaml
name: isin error: { 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
---
valid:rule.yaml
name: iso31661a args: [{ default: 0 }] error: { 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.
valid:rule.yaml
name: iso4217 error: { 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
---
valid:rule.yaml
name: iso639 args: [{ default: 0 }] error: { text: "must be a valid ISO 639 value" }
func ISRC ¶
ISRC reports whether or not v is a valid International Standard Recording Code.
valid:rule.yaml
name: isrc error: { text: "must be a valid ISRC" }
func ISSN ¶
ISSN reports whether or not v is a valid International Standard Serial Number.
valid:rule.yaml
name: issn error: { text: "must be a valid ISSN" }
func In ¶
In reports whether or not v is in the provided list.
valid:rule.yaml
name: in error: { text: "must be in the list" }
func Int ¶
Int reports whether or not v represents a valid integer.
valid:rule.yaml
name: int error: { 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.
valid:rule.yaml
name: json error: { text: "must be a valid JSON" }
func JWT ¶
JWT reports whether or not v is a valid JSON Web Token.
valid:rule.yaml
name: jwt error: { text: "must be a valid JWT" }
func LatLong ¶
LatLong reports whether or not v is a valid latitude-longitude coordinate string.
valid:rule.yaml
name: latlong args: - default: false options: [{ value: true, alias: dms }] error: { text: "must be a valid latitude-longitude coordinate" }
func Locale ¶
Locale reports whether or not v is a valid locale.
valid:rule.yaml
name: locale error: { text: "must be a valid locale" }
func LowerCase ¶
LowerCase reports whether or not v is an all lower-case string.
valid:rule.yaml
name: lower error: { 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"
---
valid:rule.yaml
name: mac args: [{ default: 0 }] error: { text: "must be a valid MAC" }
func MD5 ¶
MD5 reports whether or not v is a valid MD5 hash.
valid:rule.yaml
name: md5 error: { 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
---
valid:rule.yaml
name: mime error: { text: "must be a valid media type" }
func MagnetURI ¶
MagnetURI reports whether or not v is a valid magned URI.
valid:rule.yaml
name: magneturi error: { text: "must be a valid magnet URI" }
func Match ¶
Match reports whether or not v contains any match of the *registered* regular expression expr.
NOTE: expr MUST be registered upfront with RegisterRegexp otherwise Match will return false even if v matches the regular expression.
valid:rule.yaml
name: re error: text: "must match the regular expression" with_args: true
func MongoId ¶
MongoId reports whether or not v is a valid hex-encoded representation of a MongoDB ObjectId.
valid:rule.yaml
name: mongoid error: { text: "must be a valid Mongo Object Id" }
func Numeric ¶
Numeric reports whether or not v is a valid numeric string.
valid:rule.yaml
name: numeric error: { text: "string content must match a numeric value" }
func Octal ¶
Octal reports whether or not v represents a valid octal integer.
valid:rule.yaml
name: octal error: { 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.
valid:rule.yaml
name: pan error: { text: "must be a valid PAN" }
func Phone ¶
Phone reports whether or not v is a valid phone number in the country identified by the given country code cc.
valid:rule.yaml
name: phone args: [{ default: us }] error: { text: "must be a valid phone number" }
func Port ¶
Port reports whether or not v is a valid port number.
valid:rule.yaml
name: port error: { text: "must be a valid port number" }
func RGB ¶
RGB reports whether or not v is a valid RGB color.
valid:rule.yaml
name: rgb error: { 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.
valid:rule.yaml
name: ssn error: { 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/
valid:rule.yaml
name: semver error: { text: "must be a valid semver number" }
func Slug ¶
Slug reports whether or not v is a valid slug.
valid:rule.yaml
name: slug error: { 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.
valid:rule.yaml
name: strongpass args: [{ default: null }] error: { text: "must be a strong password" }
func UUID ¶
UUID reports whether or not v is a valid Universally Unique IDentifier. NOTE: only versions 3, 4, and 5 are currently supported.
valid:rule.yaml
name: uuid args: - default: 4 options: - { value: 3, alias: v3 } - { value: 4, alias: v4 } - { value: 5, alias: v5 } error: { text: "must be a valid UUID" }
func Uint ¶
Uint reports whether or not v represents a valid unsigned integer.
valid:rule.yaml
name: uint error: { text: "string content must match an unsigned integer" }
func UpperCase ¶
UpperCase reports whether or not v is an all upper-case string.
valid:rule.yaml
name: upper error: { text: "must contain only upper-case characters" }
Types ¶
type CurrencyOpts ¶
type CurrencyOpts struct {
NeedSym bool
}
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
internal/search
package search is used to find targets for the generator.
|
package search is used to find targets for the generator. |
internal
|
|