formats

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2018 License: BSD-3-Clause Imports: 7 Imported by: 4

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDate added in v1.1.0

func IsDate(s string) bool

IsDate tells whether given string is a valid full-date production as defined by RFC 3339, section 5.6.

func IsDateTime

func IsDateTime(s string) bool

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

func IsEmail(s string) bool

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 IsFormat

func IsFormat(s string) bool

IsFormat tells whether given string is a valid format that is registered.

func IsHostname

func IsHostname(s string) bool

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

func IsIPV4(s string) bool

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

func IsIPV6(s string) bool

IsIPV6 tells whether given string is a valid representation of an IPv6 address as defined in RFC 2373, section 2.2.

func IsJSONPointer

func IsJSONPointer(s string) bool

IsJSONPointer tells whether given string is a valid JSON Pointer.

Note: It returns false for JSON Pointer URI fragments.

func IsRegex

func IsRegex(s string) bool

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

func IsRelativeJSONPointer(s string) bool

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

func IsTime(s string) bool

IsTime tells whether given string is a valid full-time production as defined by RFC 3339, section 5.6.

func IsURI

func IsURI(s string) bool

IsURI tells whether given string is valid URI, according to RFC 3986.

func IsURIReference

func IsURIReference(s string) bool

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

func IsURITemplate(s string) bool

IsURITemplate tells whether given string is a valid URI Template according to RFC6570.

Current implementation does minimal validation.

func Register

func Register(name string, f Format)

Register registers Format object for given format name.

Types

type Format

type Format func(string) bool

The Format type is a function, to check whether given string is in valid format.

func Get

func Get(name string) (Format, bool)

Get returns Format object for given format name, if found.

Jump to

Keyboard shortcuts

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