stringformat

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	STRINGFORMAT_REGEX_DATE     = regex_0000_to_9999 + "-" + regex_1_to_12 + "-" + regex_1_to_31
	STRINGFORMAT_REGEX_TIME     = regex_1_to_24 + ":" + regex_0_to_59 + ":" + regex_0_to_59
	STRINGFORMAT_REGEX_DATETIME = STRINGFORMAT_REGEX_DATE + "T" + STRINGFORMAT_REGEX_TIME
	STRINGFORMAT_REGEX_DURATION = ".*"
	// https://ihateregex.io/expr/email/
	STRINGFORMAT_REGEX_EMAIL       = `[^@ \t\r\n]+@[^@ \t\r\n]+\.[^@ \t\r\n]+`
	STRINGFORMAT_REGEX_IDNEMAIL    = ".*"
	STRINGFORMAT_REGEX_HOSTNAME    = ".*"
	STRINGFORMAT_REGEX_IDNHOSTNAME = ".*"
	// https://ihateregex.io/expr/ip/
	STRINGFORMAT_REGEX_IPV4 = `(\b25[0-5]|\b2[0-4][0-9]|\b[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}`
	// https://ihateregex.io/expr/ipv6/
	STRINGFORMAT_REGEX_IPV6 = `` /* 659-byte string literal not displayed */
	// https://ihateregex.io/expr/uuid/
	STRINGFORMAT_REGEX_UUID                = "^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$"
	STRINGFORMAT_REGEX_URI                 = ".*"
	STRINGFORMAT_REGEX_URIREFERENCE        = ".*"
	STRINGFORMAT_REGEX_IRI                 = ".*"
	STRINGFORMAT_REGEX_IRIREFERENCE        = ".*"
	STRINGFORMAT_REGEX_URLTEMPLATE         = ".*"
	STRINGFORMAT_REGEX_JSONPOINTER         = ".*"
	STRINGFORMAT_REGEX_RELATIVEJSONPOINTER = ".*"

	STRINGFORMAT_REGEX = map[StringFormat]string{
		Date:                STRINGFORMAT_REGEX_DATE,
		DateTime:            STRINGFORMAT_REGEX_DATETIME,
		Time:                STRINGFORMAT_REGEX_TIME,
		Duration:            STRINGFORMAT_REGEX_DURATION,
		Email:               STRINGFORMAT_REGEX_DURATION,
		IdnEmail:            STRINGFORMAT_REGEX_DURATION,
		Hostname:            STRINGFORMAT_REGEX_HOSTNAME,
		IdnHostname:         STRINGFORMAT_REGEX_IDNHOSTNAME,
		Ipv4:                STRINGFORMAT_REGEX_IPV4,
		Uuid:                STRINGFORMAT_REGEX_UUID,
		Uri:                 STRINGFORMAT_REGEX_URI,
		UriReference:        STRINGFORMAT_REGEX_URIREFERENCE,
		Iri:                 STRINGFORMAT_REGEX_IRI,
		IriReference:        STRINGFORMAT_REGEX_IRIREFERENCE,
		UriTemplate:         STRINGFORMAT_REGEX_URLTEMPLATE,
		JsonPointer:         STRINGFORMAT_REGEX_JSONPOINTER,
		RelativeJsonPointer: STRINGFORMAT_REGEX_RELATIVEJSONPOINTER,
	}
)
View Source
var ErrInvalid = errors.New("invalid enumeration type")

Functions

func ErrorV

func ErrorV(v string) error

func Is

func Is(s string) bool

Types

type StringFormat

type StringFormat string
const (
	Date                StringFormat = "date"
	DateTime            StringFormat = "date-time"
	Duration            StringFormat = "duration"
	Email               StringFormat = "email"
	Hostname            StringFormat = "hostname"
	IdnEmail            StringFormat = "idn-email"
	IdnHostname         StringFormat = "idn-hostname"
	Ipv4                StringFormat = "ipv4"
	Ipv6                StringFormat = "ipv6"
	Iri                 StringFormat = "iri"
	IriReference        StringFormat = "iri-reference"
	JsonPointer         StringFormat = "json-pointer"
	Regex               StringFormat = "regex"
	RelativeJsonPointer StringFormat = "relative-json-pointer"
	Time                StringFormat = "time"
	Uri                 StringFormat = "uri"
	UriReference        StringFormat = "uri-reference"
	UriTemplate         StringFormat = "uri-template"
	Uuid                StringFormat = "uuid"
)

func Parse

func Parse(v string) (StringFormat, error)

func (StringFormat) MarshalJSON

func (t StringFormat) MarshalJSON() ([]byte, error)

func (StringFormat) MarshalYAML

func (t StringFormat) MarshalYAML() (interface{}, error)

func (StringFormat) String

func (t StringFormat) String() string

func (*StringFormat) UnmarshalJSON

func (t *StringFormat) UnmarshalJSON(data []byte) error

func (*StringFormat) UnmarshalYAML

func (t *StringFormat) UnmarshalYAML(unmarshal func(interface{}) error) error

Jump to

Keyboard shortcuts

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