import "github.com/go-openapi/strfmt"
Package strfmt contains custom string formats
TODO: add info on how to define and register a custom format
bson.go date.go default.go doc.go duration.go format.go time.go
const ( HostnamePattern = "" /* 168 byte string literal not displayed */ UUIDPattern = `(?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}$` UUID3Pattern = `(?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?3[0-9a-f]{3}-?[0-9a-f]{4}-?[0-9a-f]{12}$` 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 = `(?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?5[0-9a-f]{3}-?[89ab][0-9a-f]{3}-?[0-9a-f]{12}$` )
const ( // RFC3339Millis represents a ISO8601 format to millis instead of to nanos RFC3339Millis = "2006-01-02T15:04:05.000Z07:00" // RFC3339MillisNoColon represents a ISO8601 format to millis instead of to nanos RFC3339MillisNoColon = "2006-01-02T15:04:05.000Z0700" // RFC3339Micro represents a ISO8601 format to micro instead of to nano RFC3339Micro = "2006-01-02T15:04:05.000000Z07:00" // RFC3339MicroNoColon represents a ISO8601 format to micro instead of to nano RFC3339MicroNoColon = "2006-01-02T15:04:05.000000Z0700" // ISO8601LocalTime represents a ISO8601 format to ISO8601 in local time (no timezone) ISO8601LocalTime = "2006-01-02T15:04:05" // ISO8601TimeWithReducedPrecision represents a ISO8601 format with reduced precision (dropped secs) ISO8601TimeWithReducedPrecision = "2006-01-02T15:04Z" // ISO8601TimeWithReducedPrecisionLocaltime represents a ISO8601 format with reduced precision and no timezone (dropped seconds + no timezone) ISO8601TimeWithReducedPrecisionLocaltime = "2006-01-02T15:04" // ISO8601TimeUniversalSortableDateTimePattern represents a ISO8601 universal sortable date time pattern. ISO8601TimeUniversalSortableDateTimePattern = "2006-01-02 15:04:05" // 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}))$` )
const ( // RFC3339FullDate represents a full-date as specified by RFC3339 // See: http://goo.gl/xXOvVd RFC3339FullDate = "2006-01-02" )
var ( // DateTimeFormats is the collection of formats used by ParseDateTime() DateTimeFormats = []string{RFC3339Micro, RFC3339MicroNoColon, RFC3339Millis, RFC3339MillisNoColon, time.RFC3339, time.RFC3339Nano, ISO8601LocalTime, ISO8601TimeWithReducedPrecision, ISO8601TimeWithReducedPrecisionLocaltime, ISO8601TimeUniversalSortableDateTimePattern} // MarshalFormat sets the time resolution format used for marshaling time (set to milliseconds) MarshalFormat = RFC3339Millis // NormalizeTimeForMarshal provides a normalization function on time befeore marshalling (e.g. time.UTC). // By default, the time value is not changed. NormalizeTimeForMarshal = func(t time.Time) time.Time { return t } )
var Default = NewSeededFormats(nil, nil)
Default is the default formats registry
DefaultNameNormalizer removes all dashes
IsBSONObjectID returns true when the string is a valid BSON.ObjectId
IsDate returns true when the string is a valid date
IsDateTime returns true when the string is a valid date-time
IsDuration returns true if the provided string is a valid duration
IsEmail validates an email address.
IsHostname returns true when the string is a valid hostname
IsUUID returns true is the string matches a UUID, upper case is allowed
IsUUID3 returns true is the string matches a UUID, upper case is allowed
IsUUID4 returns true is the string matches a UUID, upper case is allowed
IsUUID5 returns true is the string matches a UUID, upper case is allowed
ParseDuration parses a duration from a string, compatible with scala duration syntax
Base64 represents a base64 encoded string, using URLEncoding alphabet
swagger:strfmt byte
DeepCopy copies the receiver into a new Base64.
DeepCopyInto copies the receiver and writes its value into out.
MarshalBSON document from this value
MarshalJSON returns the Base64 as JSON
MarshalText turns this instance into text
Scan read a value from a database driver
UnmarshalBSON document into this value
UnmarshalJSON sets the Base64 from JSON
UnmarshalText hydrates this instance from text
Value converts a value to a database driver value
CIDR represents a Classless Inter-Domain Routing notation
swagger:strfmt cidr
DeepCopy copies the receiver into a new CIDR.
DeepCopyInto copies the receiver and writes its value into out.
MarshalBSON document from this value
MarshalJSON returns the CIDR as JSON
MarshalText turns this instance into text
Scan read a value from a database driver
UnmarshalBSON document into this value
UnmarshalJSON sets the CIDR from JSON
UnmarshalText hydrates this instance from text
Value converts a value to a database driver value
CreditCard represents a credit card string format
swagger:strfmt creditcard
func (u *CreditCard) DeepCopy() *CreditCard
DeepCopy copies the receiver into a new CreditCard.
func (u *CreditCard) DeepCopyInto(out *CreditCard)
DeepCopyInto copies the receiver and writes its value into out.
func (u CreditCard) MarshalBSON() ([]byte, error)
MarshalBSON document from this value
func (u CreditCard) MarshalJSON() ([]byte, error)
MarshalJSON returns the CreditCard as JSON
func (u CreditCard) MarshalText() ([]byte, error)
MarshalText turns this instance into text
func (u *CreditCard) Scan(raw interface{}) error
Scan read a value from a database driver
func (u CreditCard) String() string
func (u *CreditCard) UnmarshalBSON(data []byte) error
UnmarshalBSON document into this value
func (u *CreditCard) UnmarshalJSON(data []byte) error
UnmarshalJSON sets the CreditCard from JSON
func (u *CreditCard) UnmarshalText(data []byte) error
UnmarshalText hydrates this instance from text
func (u CreditCard) Value() (driver.Value, error)
Value converts a value to a database driver value
Date represents a date from the API
swagger:strfmt date
DeepCopy copies the receiver into a new Date.
DeepCopyInto copies the receiver and writes its value into out.
Equal checks if two Date instances are equal
GobDecode implements the gob.GobDecoder interface.
GobEncode implements the gob.GobEncoder interface.
MarshalBinary implements the encoding.BinaryMarshaler interface.
MarshalJSON returns the Date as JSON
MarshalText serializes this date type to string
Scan scans a Date value from database driver type.
String converts this date into a string
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
UnmarshalJSON sets the Date from JSON
UnmarshalText parses a text representation into a date type
Value converts Date to a primitive value ready to written to a database.
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
NewDateTime is a representation of zero value for DateTime type
ParseDateTime parses a string that represents an ISO8601 time or a unix epoch
DeepCopy copies the receiver into a new DateTime.
DeepCopyInto copies the receiver and writes its value into out.
Equal checks if two DateTime instances are equal using time.Time's Equal method
GobDecode implements the gob.GobDecoder interface.
GobEncode implements the gob.GobEncoder interface.
MarshalBSON renders the DateTime as a BSON document
MarshalBSONValue is an interface implemented by types that can marshal themselves into a BSON document represented as bytes. The bytes returned must be a valid BSON document if the error is nil. Marshals a DateTime as a bsontype.DateTime, an int64 representing milliseconds since epoch.
MarshalBinary implements the encoding.BinaryMarshaler interface.
MarshalJSON returns the DateTime as JSON
MarshalText implements the text marshaller interface
Scan scans a DateTime value from database driver type.
String converts this time to a string
UnmarshalBSON reads the DateTime from a BSON document
UnmarshalBSONValue is an interface implemented by types that can unmarshal a BSON value representation of themselves. The BSON bytes and type can be assumed to be valid. UnmarshalBSONValue must copy the BSON value bytes if it wishes to retain the data after returning.
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
UnmarshalJSON sets the DateTime from JSON
UnmarshalText implements the text unmarshaller interface
Value converts DateTime to a primitive value ready to written to a database.
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
DeepCopy copies the receiver into a new Duration.
DeepCopyInto copies the receiver and writes its value into out.
MarshalJSON returns the Duration as JSON
MarshalText turns this instance into text
Scan reads a Duration value from database driver type.
String converts this duration to a string
UnmarshalJSON sets the Duration from JSON
UnmarshalText hydrates this instance from text
Value converts Duration to a primitive value ready to be written to a database.
Email represents the email string format as specified by the json schema spec
swagger:strfmt email
DeepCopy copies the receiver into a new Email.
DeepCopyInto copies the receiver and writes its value into out.
MarshalBSON document from this value
MarshalJSON returns the Email as JSON
MarshalText turns this instance into text
Scan read a value from a database driver
UnmarshalBSON document into this value
UnmarshalJSON sets the Email from JSON
UnmarshalText hydrates this instance from text
Value converts a value to a database driver value
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).
HexColor represents a hex color string format
swagger:strfmt hexcolor
DeepCopy copies the receiver into a new HexColor.
DeepCopyInto copies the receiver and writes its value into out.
MarshalBSON document from this value
MarshalJSON returns the HexColor as JSON
MarshalText turns this instance into text
Scan read a value from a database driver
UnmarshalBSON document into this value
UnmarshalJSON sets the HexColor from JSON
UnmarshalText hydrates this instance from text
Value converts a value to a database driver value
Hostname represents the hostname string format as specified by the json schema spec
swagger:strfmt hostname
DeepCopy copies the receiver into a new Hostname.
DeepCopyInto copies the receiver and writes its value into out.
MarshalBSON document from this value
MarshalJSON returns the Hostname as JSON
MarshalText turns this instance into text
Scan read a value from a database driver
UnmarshalBSON document into this value
UnmarshalJSON sets the Hostname from JSON
UnmarshalText hydrates this instance from text
Value converts a value to a database driver value
IPv4 represents an IP v4 address
swagger:strfmt ipv4
DeepCopy copies the receiver into a new IPv4.
DeepCopyInto copies the receiver and writes its value into out.
MarshalBSON document from this value
MarshalJSON returns the IPv4 as JSON
MarshalText turns this instance into text
Scan read a value from a database driver
UnmarshalBSON document into this value
UnmarshalJSON sets the IPv4 from JSON
UnmarshalText hydrates this instance from text
Value converts a value to a database driver value
IPv6 represents an IP v6 address
swagger:strfmt ipv6
DeepCopy copies the receiver into a new IPv6.
DeepCopyInto copies the receiver and writes its value into out.
MarshalBSON document from this value
MarshalJSON returns the IPv6 as JSON
MarshalText turns this instance into text
Scan read a value from a database driver
UnmarshalBSON document into this value
UnmarshalJSON sets the IPv6 from JSON
UnmarshalText hydrates this instance from text
Value converts a value to a database driver value
ISBN represents an isbn string format
swagger:strfmt isbn
DeepCopy copies the receiver into a new ISBN.
DeepCopyInto copies the receiver and writes its value into out.
MarshalBSON document from this value
MarshalJSON returns the ISBN as JSON
MarshalText turns this instance into text
Scan read a value from a database driver
UnmarshalBSON document into this value
UnmarshalJSON sets the ISBN from JSON
UnmarshalText hydrates this instance from text
Value converts a value to a database driver value
ISBN10 represents an isbn 10 string format
swagger:strfmt isbn10
DeepCopy copies the receiver into a new ISBN10.
DeepCopyInto copies the receiver and writes its value into out.
MarshalBSON document from this value
MarshalJSON returns the ISBN10 as JSON
MarshalText turns this instance into text
Scan read a value from a database driver
UnmarshalBSON document into this value
UnmarshalJSON sets the ISBN10 from JSON
UnmarshalText hydrates this instance from text
Value converts a value to a database driver value
ISBN13 represents an isbn 13 string format
swagger:strfmt isbn13
DeepCopy copies the receiver into a new ISBN13.
DeepCopyInto copies the receiver and writes its value into out.
MarshalBSON document from this value
MarshalJSON returns the ISBN13 as JSON
MarshalText turns this instance into text
Scan read a value from a database driver
UnmarshalBSON document into this value
UnmarshalJSON sets the ISBN13 from JSON
UnmarshalText hydrates this instance from text
Value converts a value to a database driver value
MAC represents a 48 bit MAC address
swagger:strfmt mac
DeepCopy copies the receiver into a new MAC.
DeepCopyInto copies the receiver and writes its value into out.
MarshalBSON document from this value
MarshalJSON returns the MAC as JSON
MarshalText turns this instance into text
Scan read a value from a database driver
UnmarshalBSON document into this value
UnmarshalJSON sets the MAC from JSON
UnmarshalText hydrates this instance from text
Value converts a value to a database driver value
NameNormalizer is a function that normalizes a format name.
ObjectId represents a BSON object ID (alias to go.mongodb.org/mongo-driver/bson/primitive.ObjectID)
swagger:strfmt bsonobjectid
NewObjectId creates a ObjectId from a Hex String
DeepCopy copies the receiver into a new ObjectId.
DeepCopyInto copies the receiver and writes its value into out.
MarshalBSON renders the object id as a BSON document
MarshalBSONValue is an interface implemented by types that can marshal themselves into a BSON document represented as bytes. The bytes returned must be a valid BSON document if the error is nil.
MarshalJSON returns the ObjectId as JSON
MarshalText turns this instance into text
Scan read a value from a database driver
UnmarshalBSON reads the objectId from a BSON document
UnmarshalBSONValue is an interface implemented by types that can unmarshal a BSON value representation of themselves. The BSON bytes and type can be assumed to be valid. UnmarshalBSONValue must copy the BSON value bytes if it wishes to retain the data after returning.
UnmarshalJSON sets the ObjectId from JSON
UnmarshalText hydrates this instance from text
Value converts a value to a database driver value
Password represents a password. This has no validations and is mainly used as a marker for UI components.
swagger:strfmt password
DeepCopy copies the receiver into a new Password.
DeepCopyInto copies the receiver and writes its value into out.
MarshalBSON document from this value
MarshalJSON returns the Password as JSON
MarshalText turns this instance into text
Scan read a value from a database driver
UnmarshalBSON document into this value
UnmarshalJSON sets the Password from JSON
UnmarshalText hydrates this instance from text
Value converts a value to a database driver value
RGBColor represents a RGB color string format
swagger:strfmt rgbcolor
DeepCopy copies the receiver into a new RGBColor.
DeepCopyInto copies the receiver and writes its value into out.
MarshalBSON document from this value
MarshalJSON returns the RGBColor as JSON
MarshalText turns this instance into text
Scan read a value from a database driver
UnmarshalBSON document into this value
UnmarshalJSON sets the RGBColor from JSON
UnmarshalText hydrates this instance from text
Value converts a value to a database driver value
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.
NewFormats creates a new formats registry seeded with the values from the default
func NewSeededFormats(seeds []knownFormat, normalizer NameNormalizer) Registry
NewSeededFormats creates a new formats registry
SSN represents a social security string format
swagger:strfmt ssn
DeepCopy copies the receiver into a new SSN.
DeepCopyInto copies the receiver and writes its value into out.
MarshalBSON document from this value
MarshalJSON returns the SSN as JSON
MarshalText turns this instance into text
Scan read a value from a database driver
UnmarshalBSON document into this value
UnmarshalJSON sets the SSN from JSON
UnmarshalText hydrates this instance from text
Value converts a value to a database driver value
URI represents the uri string format as specified by the json schema spec
swagger:strfmt uri
DeepCopy copies the receiver into a new URI.
DeepCopyInto copies the receiver and writes its value into out.
MarshalBSON document from this value
MarshalJSON returns the URI as JSON
MarshalText turns this instance into text
Scan read a value from a database driver
UnmarshalBSON document into this value
UnmarshalJSON sets the URI from JSON
UnmarshalText hydrates this instance from text
Value converts a value to a database driver value
UUID represents a uuid string format
swagger:strfmt uuid
DeepCopy copies the receiver into a new UUID.
DeepCopyInto copies the receiver and writes its value into out.
MarshalBSON document from this value
MarshalJSON returns the UUID as JSON
MarshalText turns this instance into text
Scan read a value from a database driver
UnmarshalBSON document into this value
UnmarshalJSON sets the UUID from JSON
UnmarshalText hydrates this instance from text
Value converts a value to a database driver value
UUID3 represents a uuid3 string format
swagger:strfmt uuid3
DeepCopy copies the receiver into a new UUID3.
DeepCopyInto copies the receiver and writes its value into out.
MarshalBSON document from this value
MarshalJSON returns the UUID as JSON
MarshalText turns this instance into text
Scan read a value from a database driver
UnmarshalBSON document into this value
UnmarshalJSON sets the UUID from JSON
UnmarshalText hydrates this instance from text
Value converts a value to a database driver value
UUID4 represents a uuid4 string format
swagger:strfmt uuid4
DeepCopy copies the receiver into a new UUID4.
DeepCopyInto copies the receiver and writes its value into out.
MarshalBSON document from this value
MarshalJSON returns the UUID as JSON
MarshalText turns this instance into text
Scan read a value from a database driver
UnmarshalBSON document into this value
UnmarshalJSON sets the UUID from JSON
UnmarshalText hydrates this instance from text
Value converts a value to a database driver value
UUID5 represents a uuid5 string format
swagger:strfmt uuid5
DeepCopy copies the receiver into a new UUID5.
DeepCopyInto copies the receiver and writes its value into out.
MarshalBSON document from this value
MarshalJSON returns the UUID as JSON
MarshalText turns this instance into text
Scan read a value from a database driver
UnmarshalBSON document into this value
UnmarshalJSON sets the UUID from JSON
UnmarshalText hydrates this instance from text
Value converts a value to a database driver value
Validator represents a validator for a string format.
Path | Synopsis |
---|---|
conv |
Package strfmt imports 20 packages (graph) and is imported by 2973 packages. Updated 2021-01-16. Refresh now. Tools for package owners.