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 IsDate(s string) bool
- 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 IsRelativeJSONPointer(s string) bool
- func IsTime(s string) bool
- func IsURI(s string) bool
- func IsURIReference(s string) bool
- func IsURITemplate(s string) bool
- func Register(name string, f Format)
- type Format
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsDate ¶ added in v1.1.0
IsDate tells whether given string is a valid full-date production as defined by RFC 3339, section 5.6.
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 IsRelativeJSONPointer ¶ added in v1.1.0
IsRelativeJSONPointer tells whether given string is a valid Relative JSON Pointer.
see https://tools.ietf.org/html/draft-handrews-relative-json-pointer-01#section-3
func IsTime ¶ added in v1.1.0
IsTime tells whether given string is a valid full-time production as defined by RFC 3339, section 5.6.
func IsURIReference ¶
IsURIReference tells whether given string is a valid URI Reference (either a URI or a relative-reference), according to RFC 3986.
func IsURITemplate ¶ added in v1.1.0
IsURITemplate tells whether given string is a valid URI Template according to RFC6570.
Current implementation does minimal validation.