formats

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 9 Imported by: 0

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

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

func IsDate(value string) bool

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

func IsDateTime(value string) bool

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

func IsDuration(value string) bool

IsDuration returns true if the value is a valid ISO-8601 duration. Specification: https://tools.ietf.org/html/rfc3339.

func IsEmail

func IsEmail(value string) bool

IsEmail returns true if the value is an Email. Specification: https://datatracker.ietf.org/doc/html/rfc5322.

func IsHostname

func IsHostname(value string) bool

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

func IsIPv4(value string) bool

IsIPv4 returns true if the value is a IPV4 address. Specification: http://tools.ietf.org/html/rfc2673#section-3.2.

func IsIPv6

func IsIPv6(value string) bool

IsIPv6 returns true if the value is an IPv6 address. Specification: http://tools.ietf.org/html/rfc2373#section-2.2.

func IsIdnEmail

func IsIdnEmail(value string) bool

IsIdnEmail returns true if the value is an IdnEmail. Specification: https://datatracker.ietf.org/doc/html/rfc4952.

func IsIdnHostname

func IsIdnHostname(value string) bool

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

func IsIri(value string) bool

IsIri returns true if the value is a valid Internationalized Resource Identifier. Specification: https://datatracker.ietf.org/doc/html/rfc3987.

func IsIriReference

func IsIriReference(value string) bool

IsIriReference returns true if the value is an IRI reference. Specification: https://tools.ietf.org/html/rfc3987.

func IsJsonPointer

func IsJsonPointer(value string) bool

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

func IsJsonPointerUriFragment(value string) bool

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

func IsRegex(value string) bool

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

func IsRelativeJsonPointer(value string) bool

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

func IsTime(value string) bool

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

func IsTimeWithZone(value string, strictTimeZone bool) bool

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

func IsUri(value string) bool

IsUri returns true if the value is a valid Uniform Resource Identifier. Specification: https://tools.ietf.org/html/rfc3986.

func IsUriReference

func IsUriReference(value string) bool

IsUriReference returns true if the value is a valid Uri Reference. Specification: https://tools.ietf.org/html/rfc3986.

func IsUriTemplate

func IsUriTemplate(value string) bool

IsUriTemplate returns true if the value is a valid Uri Template. Specification: https://datatracker.ietf.org/doc/html/rfc6570.

func IsUrl

func IsUrl(value string) bool

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

func IsUuid(value string) bool

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.

Directories

Path Synopsis
internal
idna
Package idna validates hostnames and internationalized hostnames with Pi's own IDNA checks (RFC 5890, 5891, 5892, 5893).
Package idna validates hostnames and internationalized hostnames with Pi's own IDNA checks (RFC 5890, 5891, 5892, 5893).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL