• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.github/H25-Oct-2019-

conv/H25-Oct-2019-

hack/H25-Oct-2019-

.editorconfigH A D25-Oct-2019539

.gitignoreH A D25-Oct-201925

.golangci.ymlH A D25-Oct-2019540

.travis.ymlH A D25-Oct-2019992

CODE_OF_CONDUCT.mdH A D25-Oct-20193.2 KiB

LICENSEH A D25-Oct-201911.1 KiB

README.mdH A D25-Oct-20193 KiB

bson.goH A D25-Oct-20194.4 KiB

bson_test.goH A D25-Oct-20191.6 KiB

date.goH A D25-Oct-20194.1 KiB

date_test.goH A D25-Oct-20194 KiB

default.goH A D25-Oct-201946 KiB

default_test.goH A D25-Oct-201918.4 KiB

doc.goH A D25-Oct-2019730

duration.goH A D25-Oct-20194.9 KiB

duration_test.goH A D25-Oct-20195.4 KiB

format.goH A D25-Oct-20197.8 KiB

format_test.goH A D25-Oct-20197.3 KiB

go.modH A D25-Oct-2019448

go.sumH A D25-Oct-20192.2 KiB

time.goH A D25-Oct-20197 KiB

time_test.goH A D25-Oct-20197.5 KiB

README.md

1# Strfmt [![Build Status](https://travis-ci.org/go-openapi/strfmt.svg?branch=master)](https://travis-ci.org/go-openapi/strfmt) [![codecov](https://codecov.io/gh/go-openapi/strfmt/branch/master/graph/badge.svg)](https://codecov.io/gh/go-openapi/strfmt) [![Slack Status](https://slackin.goswagger.io/badge.svg)](https://slackin.goswagger.io)
2
3[![license](http://img.shields.io/badge/license-Apache%20v2-orange.svg)](https://raw.githubusercontent.com/go-openapi/strfmt/master/LICENSE)
4[![GoDoc](https://godoc.org/github.com/go-openapi/strfmt?status.svg)](http://godoc.org/github.com/go-openapi/strfmt)
5[![GolangCI](https://golangci.com/badges/github.com/go-openapi/strfmt.svg)](https://golangci.com)
6[![Go Report Card](https://goreportcard.com/badge/github.com/go-openapi/strfmt)](https://goreportcard.com/report/github.com/go-openapi/strfmt)
7
8This package exposes a registry of data types to support string formats in the go-openapi toolkit.
9
10strfmt represents a well known string format such as credit card or email. The go toolkit for OpenAPI specifications knows how to deal with those.
11
12## Supported data formats
13go-openapi/strfmt follows the swagger 2.0 specification with the following formats
14defined [here](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types).
15
16It also provides convenient extensions to go-openapi users.
17
18- [x] JSON-schema draft 4 formats
19  - date-time
20  - email
21  - hostname
22  - ipv4
23  - ipv6
24  - uri
25- [x] swagger 2.0 format extensions
26  - binary
27  - byte (e.g. base64 encoded string)
28  - date (e.g. "1970-01-01")
29  - password
30- [x] go-openapi custom format extensions
31  - bsonobjectid (BSON objectID)
32  - creditcard
33  - duration (e.g. "3 weeks", "1ms")
34  - hexcolor (e.g. "#FFFFFF")
35  - isbn, isbn10, isbn13
36  - mac (e.g "01:02:03:04:05:06")
37  - rgbcolor (e.g. "rgb(100,100,100)")
38  - ssn
39  - uuid, uuid3, uuid4, uuid5
40  - cidr (e.g. "192.0.2.1/24", "2001:db8:a0b:12f0::1/32")
41
42> NOTE: as the name stands for, this package is intended to support string formatting only.
43> It does not provide validation for numerical values with swagger format extension for JSON types "number" or
44> "integer" (e.g. float, double, int32...).
45
46## Type conversion
47
48All types defined here are stringers and may be converted to strings with `.String()`.
49Note that most types defined by this package may be converted directly to string like `string(Email{})`.
50
51`Date` and `DateTime` may be converted directly to `time.Time` like `time.Time(Time{})`.
52Similarly, you can convert `Duration` to `time.Duration` as in `time.Duration(Duration{})`
53
54## Using pointers
55
56The `conv` subpackage provides helpers to convert the types to and from pointers, just like `go-openapi/swag` does
57with primitive types.
58
59## Format types
60Types defined in strfmt expose marshaling and validation capabilities.
61
62List of defined types:
63- Base64
64- CreditCard
65- Date
66- DateTime
67- Duration
68- Email
69- HexColor
70- Hostname
71- IPv4
72- IPv6
73- CIDR
74- ISBN
75- ISBN10
76- ISBN13
77- MAC
78- ObjectId
79- Password
80- RGBColor
81- SSN
82- URI
83- UUID
84- UUID3
85- UUID4
86- UUID5
87