strfmt

package module
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2018 License: Apache-2.0 Imports: 18 Imported by: 21,906

README

Strfmt Build Status codecov Slack Status

license GoDoc GolangCI Go Report Card

This package exposes a registry of data types to support string formats in the go-openapi toolkit.

strfmt represents a well known string format such as credit card or email. The go toolkit for OpenAPI specifications knows how to deal with those.

Supported data formats

go-openapi/strfmt follows the swagger 2.0 specification with the following formats defined here.

It also provides convenient extensions to go-openapi users.

  • JSON-schema draft 4 formats
    • date-time
    • email
    • hostname
    • ipv4
    • ipv6
    • uri
  • swagger 2.0 format extensions
    • binary
    • byte (e.g. base64 encoded string)
    • date (e.g. "1970-01-01")
    • password
  • go-openapi custom format extensions
    • bsonobjectid (BSON objectID)
    • creditcard
    • duration (e.g. "3 weeks", "1ms")
    • hexcolor (e.g. "#FFFFFF")
    • isbn, isbn10, isbn13
    • mac (e.g "01:02:03:04:05:06")
    • rgbcolor (e.g. "rgb(100,100,100)")
    • ssn
    • uuid, uuid3, uuid4, uuid5

NOTE: as the name stands for, this package is intended to support string formatting only. It does not provide validation for numerical values with swagger format extension for JSON types "number" or
"integer" (e.g. float, double, int32...).

Format types

Types defined in strfmt expose marshaling and validation capabilities.

List of defined types:

  • Base64
  • CreditCard
  • Date
  • DateTime
  • Duration
  • Email
  • HexColor
  • Hostname
  • IPv4
  • IPv6
  • ISBN
  • ISBN10
  • ISBN13
  • MAC
  • ObjectId
  • Password
  • RGBColor
  • SSN
  • URI
  • UUID
  • UUID3
  • UUID4
  • UUID5

Documentation

Overview

Package strfmt contains custom string formats

TODO: add info on how to define and register a custom format

Index

Constants

View Source
const (
	// HostnamePattern http://json-schema.org/latest/json-schema-validation.html#anchor114
	//  A string instance is valid against this attribute if it is a valid
	//  representation for an Internet host name, as defined by RFC 1034, section 3.1 [RFC1034].
	//  http://tools.ietf.org/html/rfc1034#section-3.5
	//  <digit> ::= any one of the ten digits 0 through 9
	//  var digit = /[0-9]/;
	//  <letter> ::= any one of the 52 alphabetic characters A through Z in upper case and a through z in lower case
	//  var letter = /[a-zA-Z]/;
	//  <let-dig> ::= <letter> | <digit>
	//  var letDig = /[0-9a-zA-Z]/;
	//  <let-dig-hyp> ::= <let-dig> | "-"
	//  var letDigHyp = /[-0-9a-zA-Z]/;
	//  <ldh-str> ::= <let-dig-hyp> | <let-dig-hyp> <ldh-str>
	//  var ldhStr = /[-0-9a-zA-Z]+/;
	//  <label> ::= <letter> [ [ <ldh-str> ] <let-dig> ]
	//  var label = /[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?/;
	//  <subdomain> ::= <label> | <subdomain> "." <label>
	//  var subdomain = /^[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?(\.[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?)*$/;
	//  <domain> ::= <subdomain> | " "
	HostnamePattern = `^[a-zA-Z0-9\p{S}\p{L}](([a-zA-Z0-9-\p{S}\p{L}]{0,63})(\.)){1,6}([a-zA-Z\p{L}]){2,}$`
	// UUIDPattern Regex for UUID that allows uppercase
	UUIDPattern = `(?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}$`
	// UUID3Pattern Regex for UUID3 that allows uppercase
	UUID3Pattern = `(?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?3[0-9a-f]{3}-?[0-9a-f]{4}-?[0-9a-f]{12}$`
	// UUID4Pattern Regex for UUID4 that allows uppercase
	UUID4Pattern = `(?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?4[0-9a-f]{3}-?[89ab][0-9a-f]{3}-?[0-9a-f]{12}$`
	// UUID5Pattern Regex for UUID5 that allows uppercase
	UUID5Pattern = `(?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?5[0-9a-f]{3}-?[89ab][0-9a-f]{3}-?[0-9a-f]{12}$`
)
View Source
const (
	// RFC3339Millis represents a ISO8601 format to millis instead of to nanos
	RFC3339Millis = "2006-01-02T15:04:05.000Z07:00"
	// RFC3339Micro represents a ISO8601 format to micro instead of to nano
	RFC3339Micro = "2006-01-02T15:04:05.000000Z07:00"
	// DateTimePattern pattern to match for the date-time format from http://tools.ietf.org/html/rfc3339#section-5.6
	DateTimePattern = `^([0-9]{2}):([0-9]{2}):([0-9]{2})(.[0-9]+)?(z|([+-][0-9]{2}:[0-9]{2}))$`
)
View Source
const (
	// RFC3339FullDate represents a full-date as specified by RFC3339
	// See: http://goo.gl/xXOvVd
	RFC3339FullDate = "2006-01-02"
)

Variables

Default is the default formats registry

View Source
var (

	// MarshalFormat sets the time resolution format used for marshaling time (set to milliseconds)
	MarshalFormat = RFC3339Millis
)

Functions

func DefaultNameNormalizer

func DefaultNameNormalizer(name string) string

DefaultNameNormalizer removes all dashes

func IsBSONObjectID

func IsBSONObjectID(str string) bool

IsBSONObjectID returns true when the string is a valid BSON.ObjectId

func IsDate

func IsDate(str string) bool

IsDate returns true when the string is a valid date

func IsDateTime

func IsDateTime(str string) bool

IsDateTime returns true when the string is a valid date-time

func IsDuration

func IsDuration(str string) bool

IsDuration returns true if the provided string is a valid duration

func IsEmail added in v0.17.1

func IsEmail(str string) bool

IsEmail validates an email address.

func IsHostname

func IsHostname(str string) bool

IsHostname returns true when the string is a valid hostname

func IsUUID

func IsUUID(str string) bool

IsUUID returns true is the string matches a UUID, upper case is allowed

func IsUUID3

func IsUUID3(str string) bool

IsUUID3 returns true is the string matches a UUID, upper case is allowed

func IsUUID4

func IsUUID4(str string) bool

IsUUID4 returns true is the string matches a UUID, upper case is allowed

func IsUUID5

func IsUUID5(str string) bool

IsUUID5 returns true is the string matches a UUID, upper case is allowed

func ParseDuration

func ParseDuration(cand string) (time.Duration, error)

ParseDuration parses a duration from a string, compatible with scala duration syntax

Types

type Base64

type Base64 []byte

Base64 represents a base64 encoded string, using URLEncoding alphabet

swagger:strfmt byte

func (*Base64) GetBSON

func (b *Base64) GetBSON() (interface{}, error)

GetBSON returns the Base64 as a bson.M{} map.

func (Base64) MarshalEasyJSON

func (b Base64) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON writes the Base64 to a easyjson.Writer

func (Base64) MarshalJSON

func (b Base64) MarshalJSON() ([]byte, error)

MarshalJSON returns the Base64 as JSON

func (Base64) MarshalText

func (b Base64) MarshalText() ([]byte, error)

MarshalText turns this instance into text

func (*Base64) Scan

func (b *Base64) Scan(raw interface{}) error

Scan read a value from a database driver

func (*Base64) SetBSON

func (b *Base64) SetBSON(raw bson.Raw) error

SetBSON sets the Base64 from raw bson data

func (Base64) String

func (b Base64) String() string

func (*Base64) UnmarshalEasyJSON

func (b *Base64) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON sets the Base64 from a easyjson.Lexer

func (*Base64) UnmarshalJSON

func (b *Base64) UnmarshalJSON(data []byte) error

UnmarshalJSON sets the Base64 from JSON

func (*Base64) UnmarshalText

func (b *Base64) UnmarshalText(data []byte) error

UnmarshalText hydrates this instance from text

func (Base64) Value

func (b Base64) Value() (driver.Value, error)

Value converts a value to a database driver value

type CreditCard

type CreditCard string

CreditCard represents a credit card string format

swagger:strfmt creditcard

func (*CreditCard) GetBSON

func (u *CreditCard) GetBSON() (interface{}, error)

GetBSON returns the CreditCard as a bson.M{} map.

func (CreditCard) MarshalEasyJSON

func (u CreditCard) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON writes the CreditCard to a easyjson.Writer

func (CreditCard) MarshalJSON

func (u CreditCard) MarshalJSON() ([]byte, error)

MarshalJSON returns the CreditCard as JSON

func (CreditCard) MarshalText

func (u CreditCard) MarshalText() ([]byte, error)

MarshalText turns this instance into text

func (*CreditCard) Scan

func (u *CreditCard) Scan(raw interface{}) error

Scan read a value from a database driver

func (*CreditCard) SetBSON

func (u *CreditCard) SetBSON(raw bson.Raw) error

SetBSON sets the CreditCard from raw bson data

func (CreditCard) String

func (u CreditCard) String() string

func (*CreditCard) UnmarshalEasyJSON

func (u *CreditCard) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON sets the CreditCard from a easyjson.Lexer

func (*CreditCard) UnmarshalJSON

func (u *CreditCard) UnmarshalJSON(data []byte) error

UnmarshalJSON sets the CreditCard from JSON

func (*CreditCard) UnmarshalText

func (u *CreditCard) UnmarshalText(data []byte) error

UnmarshalText hydrates this instance from text

func (CreditCard) Value

func (u CreditCard) Value() (driver.Value, error)

Value converts a value to a database driver value

type Date

type Date time.Time

Date represents a date from the API

swagger:strfmt date

func (*Date) GetBSON

func (d *Date) GetBSON() (interface{}, error)

GetBSON returns the Date as a bson.M{} map.

func (Date) MarshalEasyJSON

func (d Date) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON writes the Date to a easyjson.Writer

func (Date) MarshalJSON

func (d Date) MarshalJSON() ([]byte, error)

MarshalJSON returns the Date as JSON

func (Date) MarshalText

func (d Date) MarshalText() ([]byte, error)

MarshalText serializes this date type to string

func (*Date) Scan

func (d *Date) Scan(raw interface{}) error

Scan scans a Date value from database driver type.

func (*Date) SetBSON

func (d *Date) SetBSON(raw bson.Raw) error

SetBSON sets the Date from raw bson data

func (Date) String

func (d Date) String() string

String converts this date into a string

func (*Date) UnmarshalEasyJSON

func (d *Date) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON sets the Date from a easyjson.Lexer

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(data []byte) error

UnmarshalJSON sets the Date from JSON

func (*Date) UnmarshalText

func (d *Date) UnmarshalText(text []byte) error

UnmarshalText parses a text representation into a date type

func (Date) Value

func (d Date) Value() (driver.Value, error)

Value converts Date to a primitive value ready to written to a database.

type DateTime

type DateTime time.Time

DateTime is a time but it serializes to ISO8601 format with millis It knows how to read 3 different variations of a RFC3339 date time. Most APIs we encounter want either millisecond or second precision times. This just tries to make it worry-free.

swagger:strfmt date-time

func NewDateTime

func NewDateTime() DateTime

NewDateTime is a representation of zero value for DateTime type

func ParseDateTime

func ParseDateTime(data string) (DateTime, error)

ParseDateTime parses a string that represents an ISO8601 time or a unix epoch

func (*DateTime) GetBSON

func (t *DateTime) GetBSON() (interface{}, error)

GetBSON returns the DateTime as a bson.M{} map.

func (DateTime) MarshalEasyJSON

func (t DateTime) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON writes the DateTime to a easyjson.Writer

func (DateTime) MarshalJSON

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

MarshalJSON returns the DateTime as JSON

func (DateTime) MarshalText

func (t DateTime) MarshalText() ([]byte, error)

MarshalText implements the text marshaller interface

func (*DateTime) Scan

func (t *DateTime) Scan(raw interface{}) error

Scan scans a DateTime value from database driver type.

func (*DateTime) SetBSON

func (t *DateTime) SetBSON(raw bson.Raw) error

SetBSON sets the DateTime from raw bson data

func (DateTime) String

func (t DateTime) String() string

String converts this time to a string

func (*DateTime) UnmarshalEasyJSON

func (t *DateTime) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON sets the DateTime from a easyjson.Lexer

func (*DateTime) UnmarshalJSON

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

UnmarshalJSON sets the DateTime from JSON

func (*DateTime) UnmarshalText

func (t *DateTime) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller interface

func (DateTime) Value

func (t DateTime) Value() (driver.Value, error)

Value converts DateTime to a primitive value ready to written to a database.

type Duration

type Duration time.Duration

Duration represents a duration

Duration stores a period of time as a nanosecond count, with the largest repesentable duration being approximately 290 years.

swagger:strfmt duration

func (*Duration) GetBSON

func (d *Duration) GetBSON() (interface{}, error)

GetBSON returns the Duration a bson.M{} map.

func (Duration) MarshalEasyJSON

func (d Duration) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON writes the Duration to a easyjson.Writer

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() ([]byte, error)

MarshalJSON returns the Duration as JSON

func (Duration) MarshalText

func (d Duration) MarshalText() ([]byte, error)

MarshalText turns this instance into text

func (*Duration) Scan

func (d *Duration) Scan(raw interface{}) error

Scan reads a Duration value from database driver type.

func (*Duration) SetBSON

func (d *Duration) SetBSON(raw bson.Raw) error

SetBSON sets the Duration from raw bson data

func (Duration) String

func (d Duration) String() string

String converts this duration to a string

func (*Duration) UnmarshalEasyJSON

func (d *Duration) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON sets the Duration from a easyjson.Lexer

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(data []byte) error

UnmarshalJSON sets the Duration from JSON

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(data []byte) error

UnmarshalText hydrates this instance from text

func (Duration) Value

func (d Duration) Value() (driver.Value, error)

Value converts Duration to a primitive value ready to be written to a database.

type Email

type Email string

Email represents the email string format as specified by the json schema spec

swagger:strfmt email

func (*Email) GetBSON

func (e *Email) GetBSON() (interface{}, error)

GetBSON returns the Email as a bson.M{} map.

func (Email) MarshalEasyJSON

func (e Email) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON writes the Email to a easyjson.Writer

func (Email) MarshalJSON

func (e Email) MarshalJSON() ([]byte, error)

MarshalJSON returns the Email as JSON

func (Email) MarshalText

func (e Email) MarshalText() ([]byte, error)

MarshalText turns this instance into text

func (*Email) Scan

func (e *Email) Scan(raw interface{}) error

Scan read a value from a database driver

func (*Email) SetBSON

func (e *Email) SetBSON(raw bson.Raw) error

SetBSON sets the Email from raw bson data

func (Email) String

func (e Email) String() string

func (*Email) UnmarshalEasyJSON

func (e *Email) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON sets the Email from a easyjson.Lexer

func (*Email) UnmarshalJSON

func (e *Email) UnmarshalJSON(data []byte) error

UnmarshalJSON sets the Email from JSON

func (*Email) UnmarshalText

func (e *Email) UnmarshalText(data []byte) error

UnmarshalText hydrates this instance from text

func (Email) Value

func (e Email) Value() (driver.Value, error)

Value converts a value to a database driver value

type Format

type Format interface {
	String() string
	encoding.TextMarshaler
	encoding.TextUnmarshaler
}

Format represents a string format.

All implementations of Format provide a string representation and text marshaling/unmarshaling interface to be used by encoders (e.g. encoding/json).

type HexColor

type HexColor string

HexColor represents a hex color string format

swagger:strfmt hexcolor

func (*HexColor) GetBSON

func (h *HexColor) GetBSON() (interface{}, error)

GetBSON returns the HexColor as a bson.M{} map.

func (HexColor) MarshalEasyJSON

func (h HexColor) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON writes the HexColor to a easyjson.Writer

func (HexColor) MarshalJSON

func (h HexColor) MarshalJSON() ([]byte, error)

MarshalJSON returns the HexColor as JSON

func (HexColor) MarshalText

func (h HexColor) MarshalText() ([]byte, error)

MarshalText turns this instance into text

func (*HexColor) Scan

func (h *HexColor) Scan(raw interface{}) error

Scan read a value from a database driver

func (*HexColor) SetBSON

func (h *HexColor) SetBSON(raw bson.Raw) error

SetBSON sets the HexColor from raw bson data

func (HexColor) String

func (h HexColor) String() string

func (*HexColor) UnmarshalEasyJSON

func (h *HexColor) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON sets the HexColor from a easyjson.Lexer

func (*HexColor) UnmarshalJSON

func (h *HexColor) UnmarshalJSON(data []byte) error

UnmarshalJSON sets the HexColor from JSON

func (*HexColor) UnmarshalText

func (h *HexColor) UnmarshalText(data []byte) error

UnmarshalText hydrates this instance from text

func (HexColor) Value

func (h HexColor) Value() (driver.Value, error)

Value converts a value to a database driver value

type Hostname

type Hostname string

Hostname represents the hostname string format as specified by the json schema spec

swagger:strfmt hostname

func (*Hostname) GetBSON

func (h *Hostname) GetBSON() (interface{}, error)

GetBSON returns the Hostname as a bson.M{} map.

func (Hostname) MarshalEasyJSON

func (h Hostname) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON writes the Hostname to a easyjson.Writer

func (Hostname) MarshalJSON

func (h Hostname) MarshalJSON() ([]byte, error)

MarshalJSON returns the Hostname as JSON

func (Hostname) MarshalText

func (h Hostname) MarshalText() ([]byte, error)

MarshalText turns this instance into text

func (*Hostname) Scan

func (h *Hostname) Scan(raw interface{}) error

Scan read a value from a database driver

func (*Hostname) SetBSON

func (h *Hostname) SetBSON(raw bson.Raw) error

SetBSON sets the Hostname from raw bson data

func (Hostname) String

func (h Hostname) String() string

func (*Hostname) UnmarshalEasyJSON

func (h *Hostname) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON sets the Hostname from a easyjson.Lexer

func (*Hostname) UnmarshalJSON

func (h *Hostname) UnmarshalJSON(data []byte) error

UnmarshalJSON sets the Hostname from JSON

func (*Hostname) UnmarshalText

func (h *Hostname) UnmarshalText(data []byte) error

UnmarshalText hydrates this instance from text

func (Hostname) Value

func (h Hostname) Value() (driver.Value, error)

Value converts a value to a database driver value

type IPv4

type IPv4 string

IPv4 represents an IP v4 address

swagger:strfmt ipv4

func (*IPv4) GetBSON

func (u *IPv4) GetBSON() (interface{}, error)

GetBSON returns the IPv4 as a bson.M{} map.

func (IPv4) MarshalEasyJSON

func (u IPv4) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON writes the IPv4 to a easyjson.Writer

func (IPv4) MarshalJSON

func (u IPv4) MarshalJSON() ([]byte, error)

MarshalJSON returns the IPv4 as JSON

func (IPv4) MarshalText

func (u IPv4) MarshalText() ([]byte, error)

MarshalText turns this instance into text

func (*IPv4) Scan

func (u *IPv4) Scan(raw interface{}) error

Scan read a value from a database driver

func (*IPv4) SetBSON

func (u *IPv4) SetBSON(raw bson.Raw) error

SetBSON sets the IPv4 from raw bson data

func (IPv4) String

func (u IPv4) String() string

func (*IPv4) UnmarshalEasyJSON

func (u *IPv4) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON sets the IPv4 from a easyjson.Lexer

func (*IPv4) UnmarshalJSON

func (u *IPv4) UnmarshalJSON(data []byte) error

UnmarshalJSON sets the IPv4 from JSON

func (*IPv4) UnmarshalText

func (u *IPv4) UnmarshalText(data []byte) error

UnmarshalText hydrates this instance from text

func (IPv4) Value

func (u IPv4) Value() (driver.Value, error)

Value converts a value to a database driver value

type IPv6

type IPv6 string

IPv6 represents an IP v6 address

swagger:strfmt ipv6

func (*IPv6) GetBSON

func (u *IPv6) GetBSON() (interface{}, error)

GetBSON returns the IPv6 as a bson.M{} map.

func (IPv6) MarshalEasyJSON

func (u IPv6) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON writes the IPv6 to a easyjson.Writer

func (IPv6) MarshalJSON

func (u IPv6) MarshalJSON() ([]byte, error)

MarshalJSON returns the IPv6 as JSON

func (IPv6) MarshalText

func (u IPv6) MarshalText() ([]byte, error)

MarshalText turns this instance into text

func (*IPv6) Scan

func (u *IPv6) Scan(raw interface{}) error

Scan read a value from a database driver

func (*IPv6) SetBSON

func (u *IPv6) SetBSON(raw bson.Raw) error

SetBSON sets the IPv6 from raw bson data

func (IPv6) String

func (u IPv6) String() string

func (*IPv6) UnmarshalEasyJSON

func (u *IPv6) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON sets the IPv6 from a easyjson.Lexer

func (*IPv6) UnmarshalJSON

func (u *IPv6) UnmarshalJSON(data []byte) error

UnmarshalJSON sets the IPv6 from JSON

func (*IPv6) UnmarshalText

func (u *IPv6) UnmarshalText(data []byte) error

UnmarshalText hydrates this instance from text

func (IPv6) Value

func (u IPv6) Value() (driver.Value, error)

Value converts a value to a database driver value

type ISBN

type ISBN string

ISBN represents an isbn string format

swagger:strfmt isbn

func (*ISBN) GetBSON

func (u *ISBN) GetBSON() (interface{}, error)

GetBSON returns the ISBN as a bson.M{} map.

func (ISBN) MarshalEasyJSON

func (u ISBN) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON writes the ISBN to a easyjson.Writer

func (ISBN) MarshalJSON

func (u ISBN) MarshalJSON() ([]byte, error)

MarshalJSON returns the ISBN as JSON

func (ISBN) MarshalText

func (u ISBN) MarshalText() ([]byte, error)

MarshalText turns this instance into text

func (*ISBN) Scan

func (u *ISBN) Scan(raw interface{}) error

Scan read a value from a database driver

func (*ISBN) SetBSON

func (u *ISBN) SetBSON(raw bson.Raw) error

SetBSON sets the ISBN from raw bson data

func (ISBN) String

func (u ISBN) String() string

func (*ISBN) UnmarshalEasyJSON

func (u *ISBN) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON sets the ISBN from a easyjson.Lexer

func (*ISBN) UnmarshalJSON

func (u *ISBN) UnmarshalJSON(data []byte) error

UnmarshalJSON sets the ISBN from JSON

func (*ISBN) UnmarshalText

func (u *ISBN) UnmarshalText(data []byte) error

UnmarshalText hydrates this instance from text

func (ISBN) Value

func (u ISBN) Value() (driver.Value, error)

Value converts a value to a database driver value

type ISBN10

type ISBN10 string

ISBN10 represents an isbn 10 string format

swagger:strfmt isbn10

func (*ISBN10) GetBSON

func (u *ISBN10) GetBSON() (interface{}, error)

GetBSON returns the ISBN10 as a bson.M{} map.

func (ISBN10) MarshalEasyJSON

func (u ISBN10) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON writes the ISBN10 to a easyjson.Writer

func (ISBN10) MarshalJSON

func (u ISBN10) MarshalJSON() ([]byte, error)

MarshalJSON returns the ISBN10 as JSON

func (ISBN10) MarshalText

func (u ISBN10) MarshalText() ([]byte, error)

MarshalText turns this instance into text

func (*ISBN10) Scan

func (u *ISBN10) Scan(raw interface{}) error

Scan read a value from a database driver

func (*ISBN10) SetBSON

func (u *ISBN10) SetBSON(raw bson.Raw) error

SetBSON sets the ISBN10 from raw bson data

func (ISBN10) String

func (u ISBN10) String() string

func (*ISBN10) UnmarshalEasyJSON

func (u *ISBN10) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON sets the ISBN10 from a easyjson.Lexer

func (*ISBN10) UnmarshalJSON

func (u *ISBN10) UnmarshalJSON(data []byte) error

UnmarshalJSON sets the ISBN10 from JSON

func (*ISBN10) UnmarshalText

func (u *ISBN10) UnmarshalText(data []byte) error

UnmarshalText hydrates this instance from text

func (ISBN10) Value

func (u ISBN10) Value() (driver.Value, error)

Value converts a value to a database driver value

type ISBN13

type ISBN13 string

ISBN13 represents an isbn 13 string format

swagger:strfmt isbn13

func (*ISBN13) GetBSON

func (u *ISBN13) GetBSON() (interface{}, error)

GetBSON returns the ISBN13 as a bson.M{} map.

func (ISBN13) MarshalEasyJSON

func (u ISBN13) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON writes the ISBN13 to a easyjson.Writer

func (ISBN13) MarshalJSON

func (u ISBN13) MarshalJSON() ([]byte, error)

MarshalJSON returns the ISBN13 as JSON

func (ISBN13) MarshalText

func (u ISBN13) MarshalText() ([]byte, error)

MarshalText turns this instance into text

func (*ISBN13) Scan

func (u *ISBN13) Scan(raw interface{}) error

Scan read a value from a database driver

func (*ISBN13) SetBSON

func (u *ISBN13) SetBSON(raw bson.Raw) error

SetBSON sets the ISBN13 from raw bson data

func (ISBN13) String

func (u ISBN13) String() string

func (*ISBN13) UnmarshalEasyJSON

func (u *ISBN13) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON sets the ISBN13 from a easyjson.Lexer

func (*ISBN13) UnmarshalJSON

func (u *ISBN13) UnmarshalJSON(data []byte) error

UnmarshalJSON sets the ISBN13 from JSON

func (*ISBN13) UnmarshalText

func (u *ISBN13) UnmarshalText(data []byte) error

UnmarshalText hydrates this instance from text

func (ISBN13) Value

func (u ISBN13) Value() (driver.Value, error)

Value converts a value to a database driver value

type MAC

type MAC string

MAC represents a 48 bit MAC address

swagger:strfmt mac

func (*MAC) GetBSON

func (u *MAC) GetBSON() (interface{}, error)

GetBSON returns the MAC as a bson.M{} map.

func (MAC) MarshalEasyJSON

func (u MAC) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON writes the MAC to a easyjson.Writer

func (MAC) MarshalJSON

func (u MAC) MarshalJSON() ([]byte, error)

MarshalJSON returns the MAC as JSON

func (MAC) MarshalText

func (u MAC) MarshalText() ([]byte, error)

MarshalText turns this instance into text

func (*MAC) Scan

func (u *MAC) Scan(raw interface{}) error

Scan read a value from a database driver

func (*MAC) SetBSON

func (u *MAC) SetBSON(raw bson.Raw) error

SetBSON sets the MAC from raw bson data

func (MAC) String

func (u MAC) String() string

func (*MAC) UnmarshalEasyJSON

func (u *MAC) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON sets the MAC from a easyjson.Lexer

func (*MAC) UnmarshalJSON

func (u *MAC) UnmarshalJSON(data []byte) error

UnmarshalJSON sets the MAC from JSON

func (*MAC) UnmarshalText

func (u *MAC) UnmarshalText(data []byte) error

UnmarshalText hydrates this instance from text

func (MAC) Value

func (u MAC) Value() (driver.Value, error)

Value converts a value to a database driver value

type NameNormalizer

type NameNormalizer func(string) string

NameNormalizer is a function that normalizes a format name.

type ObjectId

type ObjectId bson.ObjectId

ObjectId represents a BSON object ID (alias to github.com/globalsign/mgo/bson.ObjectId)

swagger:strfmt bsonobjectid

func NewObjectId

func NewObjectId(hex string) ObjectId

NewObjectId creates a ObjectId from a Hex String

func (*ObjectId) GetBSON

func (id *ObjectId) GetBSON() (interface{}, error)

GetBSON returns the hex representation of the ObjectId as a bson.M{} map.

func (*ObjectId) MarshalEasyJSON

func (id *ObjectId) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON writes the ObjectId to a easyjson.Writer

func (*ObjectId) MarshalJSON

func (id *ObjectId) MarshalJSON() ([]byte, error)

MarshalJSON returns the ObjectId as JSON

func (*ObjectId) MarshalText

func (id *ObjectId) MarshalText() ([]byte, error)

MarshalText turns this instance into text

func (*ObjectId) Scan

func (id *ObjectId) Scan(raw interface{}) error

Scan read a value from a database driver

func (*ObjectId) SetBSON

func (id *ObjectId) SetBSON(raw bson.Raw) error

SetBSON sets the ObjectId from raw bson data

func (*ObjectId) String

func (id *ObjectId) String() string

func (*ObjectId) UnmarshalEasyJSON

func (id *ObjectId) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON sets the ObjectId from a easyjson.Lexer

func (*ObjectId) UnmarshalJSON

func (id *ObjectId) UnmarshalJSON(data []byte) error

UnmarshalJSON sets the ObjectId from JSON

func (*ObjectId) UnmarshalText

func (id *ObjectId) UnmarshalText(data []byte) error

UnmarshalText hydrates this instance from text

func (*ObjectId) Value

func (id *ObjectId) Value() (driver.Value, error)

Value converts a value to a database driver value

type Password

type Password string

Password represents a password. This has no validations and is mainly used as a marker for UI components.

swagger:strfmt password

func (*Password) GetBSON

func (r *Password) GetBSON() (interface{}, error)

GetBSON returns the Password as a bson.M{} map.

func (Password) MarshalEasyJSON

func (r Password) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON writes the Password to a easyjson.Writer

func (Password) MarshalJSON

func (r Password) MarshalJSON() ([]byte, error)

MarshalJSON returns the Password as JSON

func (Password) MarshalText

func (r Password) MarshalText() ([]byte, error)

MarshalText turns this instance into text

func (*Password) Scan

func (r *Password) Scan(raw interface{}) error

Scan read a value from a database driver

func (*Password) SetBSON

func (r *Password) SetBSON(raw bson.Raw) error

SetBSON sets the Password from raw bson data

func (Password) String

func (r Password) String() string

func (*Password) UnmarshalEasyJSON

func (r *Password) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON sets the Password from a easyjson.Lexer

func (*Password) UnmarshalJSON

func (r *Password) UnmarshalJSON(data []byte) error

UnmarshalJSON sets the Password from JSON

func (*Password) UnmarshalText

func (r *Password) UnmarshalText(data []byte) error

UnmarshalText hydrates this instance from text

func (Password) Value

func (r Password) Value() (driver.Value, error)

Value converts a value to a database driver value

type RGBColor

type RGBColor string

RGBColor represents a RGB color string format

swagger:strfmt rgbcolor

func (*RGBColor) GetBSON

func (r *RGBColor) GetBSON() (interface{}, error)

GetBSON returns the RGBColor as a bson.M{} map.

func (RGBColor) MarshalEasyJSON

func (r RGBColor) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON writes the RGBColor to a easyjson.Writer

func (RGBColor) MarshalJSON

func (r RGBColor) MarshalJSON() ([]byte, error)

MarshalJSON returns the RGBColor as JSON

func (RGBColor) MarshalText

func (r RGBColor) MarshalText() ([]byte, error)

MarshalText turns this instance into text

func (*RGBColor) Scan

func (r *RGBColor) Scan(raw interface{}) error

Scan read a value from a database driver

func (*RGBColor) SetBSON

func (r *RGBColor) SetBSON(raw bson.Raw) error

SetBSON sets the RGBColor from raw bson data

func (RGBColor) String

func (r RGBColor) String() string

func (*RGBColor) UnmarshalEasyJSON

func (r *RGBColor) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON sets the RGBColor from a easyjson.Lexer

func (*RGBColor) UnmarshalJSON

func (r *RGBColor) UnmarshalJSON(data []byte) error

UnmarshalJSON sets the RGBColor from JSON

func (*RGBColor) UnmarshalText

func (r *RGBColor) UnmarshalText(data []byte) error

UnmarshalText hydrates this instance from text

func (RGBColor) Value

func (r RGBColor) Value() (driver.Value, error)

Value converts a value to a database driver value

type Registry

type Registry interface {
	Add(string, Format, Validator) bool
	DelByName(string) bool
	GetType(string) (reflect.Type, bool)
	ContainsName(string) bool
	Validates(string, string) bool
	Parse(string, string) (interface{}, error)
	MapStructureHookFunc() mapstructure.DecodeHookFunc
}

Registry is a registry of string formats, with a validation method.

func NewFormats

func NewFormats() Registry

NewFormats creates a new formats registry seeded with the values from the default

func NewSeededFormats

func NewSeededFormats(seeds []knownFormat, normalizer NameNormalizer) Registry

NewSeededFormats creates a new formats registry

type SSN

type SSN string

SSN represents a social security string format

swagger:strfmt ssn

func (*SSN) GetBSON

func (u *SSN) GetBSON() (interface{}, error)

GetBSON returns the SSN as a bson.M{} map.

func (SSN) MarshalEasyJSON

func (u SSN) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON writes the SSN to a easyjson.Writer

func (SSN) MarshalJSON

func (u SSN) MarshalJSON() ([]byte, error)

MarshalJSON returns the SSN as JSON

func (SSN) MarshalText

func (u SSN) MarshalText() ([]byte, error)

MarshalText turns this instance into text

func (*SSN) Scan

func (u *SSN) Scan(raw interface{}) error

Scan read a value from a database driver

func (*SSN) SetBSON

func (u *SSN) SetBSON(raw bson.Raw) error

SetBSON sets the SSN from raw bson data

func (SSN) String

func (u SSN) String() string

func (*SSN) UnmarshalEasyJSON

func (u *SSN) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON sets the SSN from a easyjson.Lexer

func (*SSN) UnmarshalJSON

func (u *SSN) UnmarshalJSON(data []byte) error

UnmarshalJSON sets the SSN from JSON

func (*SSN) UnmarshalText

func (u *SSN) UnmarshalText(data []byte) error

UnmarshalText hydrates this instance from text

func (SSN) Value

func (u SSN) Value() (driver.Value, error)

Value converts a value to a database driver value

type URI

type URI string

URI represents the uri string format as specified by the json schema spec

swagger:strfmt uri

func (*URI) GetBSON

func (u *URI) GetBSON() (interface{}, error)

GetBSON returns the URI as a bson.M{} map.

func (URI) MarshalEasyJSON

func (u URI) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON writes the URI to a easyjson.Writer

func (URI) MarshalJSON

func (u URI) MarshalJSON() ([]byte, error)

MarshalJSON returns the URI as JSON

func (URI) MarshalText

func (u URI) MarshalText() ([]byte, error)

MarshalText turns this instance into text

func (*URI) Scan

func (u *URI) Scan(raw interface{}) error

Scan read a value from a database driver

func (*URI) SetBSON

func (u *URI) SetBSON(raw bson.Raw) error

SetBSON sets the URI from raw bson data

func (URI) String

func (u URI) String() string

func (*URI) UnmarshalEasyJSON

func (u *URI) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON sets the URI from a easyjson.Lexer

func (*URI) UnmarshalJSON

func (u *URI) UnmarshalJSON(data []byte) error

UnmarshalJSON sets the URI from JSON

func (*URI) UnmarshalText

func (u *URI) UnmarshalText(data []byte) error

UnmarshalText hydrates this instance from text

func (URI) Value

func (u URI) Value() (driver.Value, error)

Value converts a value to a database driver value

type UUID

type UUID string

UUID represents a uuid string format

swagger:strfmt uuid

func (*UUID) GetBSON

func (u *UUID) GetBSON() (interface{}, error)

GetBSON returns the UUID as a bson.M{} map.

func (UUID) MarshalEasyJSON

func (u UUID) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON writes the UUID to a easyjson.Writer

func (UUID) MarshalJSON

func (u UUID) MarshalJSON() ([]byte, error)

MarshalJSON returns the UUID as JSON

func (UUID) MarshalText

func (u UUID) MarshalText() ([]byte, error)

MarshalText turns this instance into text

func (*UUID) Scan

func (u *UUID) Scan(raw interface{}) error

Scan read a value from a database driver

func (*UUID) SetBSON

func (u *UUID) SetBSON(raw bson.Raw) error

SetBSON sets the UUID from raw bson data

func (UUID) String

func (u UUID) String() string

func (*UUID) UnmarshalEasyJSON

func (u *UUID) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON sets the UUID from a easyjson.Lexer

func (*UUID) UnmarshalJSON

func (u *UUID) UnmarshalJSON(data []byte) error

UnmarshalJSON sets the UUID from JSON

func (*UUID) UnmarshalText

func (u *UUID) UnmarshalText(data []byte) error

UnmarshalText hydrates this instance from text

func (UUID) Value

func (u UUID) Value() (driver.Value, error)

Value converts a value to a database driver value

type UUID3

type UUID3 string

UUID3 represents a uuid3 string format

swagger:strfmt uuid3

func (*UUID3) GetBSON

func (u *UUID3) GetBSON() (interface{}, error)

GetBSON returns the UUID3 as a bson.M{} map.

func (UUID3) MarshalEasyJSON

func (u UUID3) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON writes the UUID3 to a easyjson.Writer

func (UUID3) MarshalJSON

func (u UUID3) MarshalJSON() ([]byte, error)

MarshalJSON returns the UUID3 as JSON

func (UUID3) MarshalText

func (u UUID3) MarshalText() ([]byte, error)

MarshalText turns this instance into text

func (*UUID3) Scan

func (u *UUID3) Scan(raw interface{}) error

Scan read a value from a database driver

func (*UUID3) SetBSON

func (u *UUID3) SetBSON(raw bson.Raw) error

SetBSON sets the UUID3 from raw bson data

func (UUID3) String

func (u UUID3) String() string

func (*UUID3) UnmarshalEasyJSON

func (u *UUID3) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON sets the UUID3 from a easyjson.Lexer

func (*UUID3) UnmarshalJSON

func (u *UUID3) UnmarshalJSON(data []byte) error

UnmarshalJSON sets the UUID3 from JSON

func (*UUID3) UnmarshalText

func (u *UUID3) UnmarshalText(data []byte) error

UnmarshalText hydrates this instance from text

func (UUID3) Value

func (u UUID3) Value() (driver.Value, error)

Value converts a value to a database driver value

type UUID4

type UUID4 string

UUID4 represents a uuid4 string format

swagger:strfmt uuid4

func (*UUID4) GetBSON

func (u *UUID4) GetBSON() (interface{}, error)

GetBSON returns the UUID4 as a bson.M{} map.

func (UUID4) MarshalEasyJSON

func (u UUID4) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON writes the UUID4 to a easyjson.Writer

func (UUID4) MarshalJSON

func (u UUID4) MarshalJSON() ([]byte, error)

MarshalJSON returns the UUID4 as JSON

func (UUID4) MarshalText

func (u UUID4) MarshalText() ([]byte, error)

MarshalText turns this instance into text

func (*UUID4) Scan

func (u *UUID4) Scan(raw interface{}) error

Scan read a value from a database driver

func (*UUID4) SetBSON

func (u *UUID4) SetBSON(raw bson.Raw) error

SetBSON sets the UUID4 from raw bson data

func (UUID4) String

func (u UUID4) String() string

func (*UUID4) UnmarshalEasyJSON

func (u *UUID4) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON sets the UUID4 from a easyjson.Lexer

func (*UUID4) UnmarshalJSON

func (u *UUID4) UnmarshalJSON(data []byte) error

UnmarshalJSON sets the UUID4 from JSON

func (*UUID4) UnmarshalText

func (u *UUID4) UnmarshalText(data []byte) error

UnmarshalText hydrates this instance from text

func (UUID4) Value

func (u UUID4) Value() (driver.Value, error)

Value converts a value to a database driver value

type UUID5

type UUID5 string

UUID5 represents a uuid5 string format

swagger:strfmt uuid5

func (*UUID5) GetBSON

func (u *UUID5) GetBSON() (interface{}, error)

GetBSON returns the UUID5 as a bson.M{} map.

func (UUID5) MarshalEasyJSON

func (u UUID5) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON writes the UUID5 to a easyjson.Writer

func (UUID5) MarshalJSON

func (u UUID5) MarshalJSON() ([]byte, error)

MarshalJSON returns the UUID5 as JSON

func (UUID5) MarshalText

func (u UUID5) MarshalText() ([]byte, error)

MarshalText turns this instance into text

func (*UUID5) Scan

func (u *UUID5) Scan(raw interface{}) error

Scan read a value from a database driver

func (*UUID5) SetBSON

func (u *UUID5) SetBSON(raw bson.Raw) error

SetBSON sets the UUID5 from raw bson data

func (UUID5) String

func (u UUID5) String() string

func (*UUID5) UnmarshalEasyJSON

func (u *UUID5) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON sets the UUID5 from a easyjson.Lexer

func (*UUID5) UnmarshalJSON

func (u *UUID5) UnmarshalJSON(data []byte) error

UnmarshalJSON sets the UUID5 from JSON

func (*UUID5) UnmarshalText

func (u *UUID5) UnmarshalText(data []byte) error

UnmarshalText hydrates this instance from text

func (UUID5) Value

func (u UUID5) Value() (driver.Value, error)

Value converts a value to a database driver value

type Validator

type Validator func(string) bool

Validator represents a validator for a string format.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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