Documentation ¶
Overview ¶
Package formats provides functions to check string against format.
It allows developers to register custom formats, that can be used in json-schema for validation.
Index ¶
- func IsDateTime(s string) bool
- func IsEmail(s string) bool
- func IsFormat(s string) bool
- func IsHostname(s string) bool
- func IsIPV4(s string) bool
- func IsIPV6(s string) bool
- func IsJSONPointer(s string) bool
- func IsRegex(s string) bool
- func IsURI(s string) bool
- func IsURIReference(s string) bool
- func Register(name string, f Format)
- type Format
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsDateTime ¶
IsDateTime tells whether given string is a valid date representation as defined by RFC 3339, section 5.6.
Note: this is unable to parse UTC leap seconds. See https://github.com/golang/go/issues/8728.
func IsEmail ¶
IsEmail tells whether given string is a valid Internet email address as defined by RFC 5322, section 3.4.1.
See https://en.wikipedia.org/wiki/Email_address, for details.
func IsHostname ¶
IsHostname tells whether given string is a valid representation for an Internet host name, as defined by RFC 1034, section 3.1.
See https://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names, for details.
func IsIPV4 ¶
IsIPV4 tells whether given string is a valid representation of an IPv4 address according to the "dotted-quad" ABNF syntax as defined in RFC 2673, section 3.2.
func IsIPV6 ¶
IsIPV6 tells whether given string is a valid representation of an IPv6 address as defined in RFC 2373, section 2.2.
func IsJSONPointer ¶
IsJSONPointer tells whether given string is a valid JSON Pointer.
Note: It returns false for JSON Pointer URI fragments.
func IsRegex ¶
IsRegex tells whether given string is a valid regular expression, according to the ECMA 262 regular expression dialect.
The implementation uses go-lang regexp package.
func IsURIReference ¶
IsURIReference tells whether given string is a valid URI Reference (either a URI or a relative-reference), according to RFC 3986.