Documentation
¶
Overview ¶
Package formats holds the format checks of JSON Schema 2020-12, for the schema package's formats option. An optional entry point: schemas compiled without it treat `format` as an annotation and do not link these checks. The checks are adapted from TypeBox 1.3.27 (MIT).
Index ¶
- func Formats() map[string]schema.FormatCheck
- func IsDate(value string) bool
- func IsDateTime(value string) bool
- func IsDuration(value string) bool
- func IsEmail(value string) bool
- func IsHostname(value string) bool
- func IsIPv4(value string) bool
- func IsIPv6(value string) bool
- func IsIdnEmail(value string) bool
- func IsIdnHostname(value string) bool
- func IsIri(value string) bool
- func IsIriReference(value string) bool
- func IsJsonPointer(value string) bool
- func IsJsonPointerUriFragment(value string) bool
- func IsRegex(value string) bool
- func IsRelativeJsonPointer(value string) bool
- func IsTime(value string) bool
- func IsTimeWithZone(value string, strictTimeZone bool) bool
- func IsUri(value string) bool
- func IsUriReference(value string) bool
- func IsUriTemplate(value string) bool
- func IsUrl(value string) bool
- func IsUuid(value string) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Formats ¶
func Formats() map[string]schema.FormatCheck
Formats is Pi's `formats` export: every format JSON Schema 2020-12 defines, by name, plus `url` and `json-pointer-uri-fragment`, which TypeBox and ajv-formats also check. It returns a new map on each call.
func IsDate ¶
IsDate returns true if the value is a ISO8601 Date component string. Specification: https://datatracker.ietf.org/doc/html/rfc3339. Example: `2020-12-12`.
func IsDateTime ¶
IsDateTime returns true if the value is a ISO8601 DateTime string. Specification: https://datatracker.ietf.org/doc/html/rfc3339. Example: `2020-12-12T20:20:40+00:00`.
func IsDuration ¶
IsDuration returns true if the value is a valid ISO-8601 duration. Specification: https://tools.ietf.org/html/rfc3339.
func IsEmail ¶
IsEmail returns true if the value is an Email. Specification: https://datatracker.ietf.org/doc/html/rfc5322.
func IsHostname ¶
IsHostname returns true if the value is a valid hostname. Specifications: https://tools.ietf.org/html/rfc1123, https://tools.ietf.org/html/rfc5891, https://tools.ietf.org/html/rfc5892.
func IsIPv4 ¶
IsIPv4 returns true if the value is a IPV4 address. Specification: http://tools.ietf.org/html/rfc2673#section-3.2.
func IsIPv6 ¶
IsIPv6 returns true if the value is an IPv6 address. Specification: http://tools.ietf.org/html/rfc2373#section-2.2.
func IsIdnEmail ¶
IsIdnEmail returns true if the value is an IdnEmail. Specification: https://datatracker.ietf.org/doc/html/rfc4952.
func IsIdnHostname ¶
IsIdnHostname returns true if the value is a valid internationalized (IDN) hostname. Specifications: https://tools.ietf.org/html/rfc3490, https://tools.ietf.org/html/rfc5891, https://tools.ietf.org/html/rfc5892, https://tools.ietf.org/html/rfc5893.
func IsIri ¶
IsIri returns true if the value is a valid Internationalized Resource Identifier. Specification: https://datatracker.ietf.org/doc/html/rfc3987.
func IsIriReference ¶
IsIriReference returns true if the value is an IRI reference. Specification: https://tools.ietf.org/html/rfc3987.
func IsJsonPointer ¶
IsJsonPointer returns true if the value is a json pointer. Specification: https://datatracker.ietf.org/doc/html/rfc6901. Source: https://github.com/ajv-validator/ajv-formats.
func IsJsonPointerUriFragment ¶
IsJsonPointerUriFragment returns true if the value is a json pointer uri fragment. Specification: https://datatracker.ietf.org/doc/html/rfc6901. Source: https://github.com/ajv-validator/ajv-formats.
func IsRegex ¶
IsRegex returns true if the value is a regular expression string pattern, that is, `new RegExp(value, "u")` does not throw. Specification: https://ecma-international.org/ecma-262.
func IsRelativeJsonPointer ¶
IsRelativeJsonPointer returns true if the value is a relative json pointer. Specification: https://datatracker.ietf.org/doc/html/rfc6901. Source: https://github.com/ajv-validator/ajv-formats.
func IsTime ¶
IsTime returns true if the value is an ISO time string that carries a time zone. Specification: https://datatracker.ietf.org/doc/html/rfc3339.
func IsTimeWithZone ¶
IsTimeWithZone is Pi's IsTime with its optional strictTimeZone argument: when strictTimeZone is true the value must end in a time zone offset or "Z"/"z".
func IsUri ¶
IsUri returns true if the value is a valid Uniform Resource Identifier. Specification: https://tools.ietf.org/html/rfc3986.
func IsUriReference ¶
IsUriReference returns true if the value is a valid Uri Reference. Specification: https://tools.ietf.org/html/rfc3986.
func IsUriTemplate ¶
IsUriTemplate returns true if the value is a valid Uri Template. Specification: https://datatracker.ietf.org/doc/html/rfc6570.
func IsUrl ¶
IsUrl returns true if the value is a valid Uniform Resource Locator, as Node's `URL.canParse` decides. canParse takes a USVString: a surrogate pair written as two WTF-8 halves is one code point and a lone surrogate is U+FFFD. Specification: https://datatracker.ietf.org/doc/html/rfc3986 and https://datatracker.ietf.org/doc/html/rfc3987.
func IsUuid ¶
IsUuid returns true if the value is a uuid. Specifications: https://www.rfc-editor.org/info/rfc4122/, https://www.rfc-editor.org/info/rfc9562/.
Types ¶
This section is empty.
Source Files
¶
- index.go
- typebox_date.go
- typebox_date_time.go
- typebox_duration.go
- typebox_email.go
- typebox_hostname.go
- typebox_idn_email.go
- typebox_idn_hostname.go
- typebox_ipv4.go
- typebox_ipv6.go
- typebox_iri.go
- typebox_iri_reference.go
- typebox_json_pointer.go
- typebox_json_pointer_uri_fragment.go
- typebox_regex.go
- typebox_relative_json_pointer.go
- typebox_time.go
- typebox_uri.go
- typebox_uri_reference.go
- typebox_uri_template.go
- typebox_url.go
- typebox_uuid.go
- unary_plus.go