pax_global_header00006660000000000000000000000064134451762560014527gustar00rootroot0000000000000052 comment=29177d4b5db488583bb97ebc05d3842ebeda91a8 golang-github-go-openapi-strfmt-0.19.0/000077500000000000000000000000001344517625600177165ustar00rootroot00000000000000golang-github-go-openapi-strfmt-0.19.0/.editorconfig000066400000000000000000000010331344517625600223700ustar00rootroot00000000000000# top-most EditorConfig file root = true # Unix-style newlines with a newline ending every file [*] end_of_line = lf insert_final_newline = true indent_style = space indent_size = 2 trim_trailing_whitespace = true # Set default charset [*.{js,py,go,scala,rb,java,html,css,less,sass,md}] charset = utf-8 # Tab indentation (no size specified) [*.go] indent_style = tab [*.md] trim_trailing_whitespace = false # Matches the exact files either package.json or .travis.yml [{package.json,.travis.yml}] indent_style = space indent_size = 2 golang-github-go-openapi-strfmt-0.19.0/.github/000077500000000000000000000000001344517625600212565ustar00rootroot00000000000000golang-github-go-openapi-strfmt-0.19.0/.github/CONTRIBUTING.md000066400000000000000000000114601344517625600235110ustar00rootroot00000000000000## Contribution Guidelines ### Pull requests are always welcome We are always thrilled to receive pull requests, and do our best to process them as fast as possible. Not sure if that typo is worth a pull request? Do it! We will appreciate it. If your pull request is not accepted on the first try, don't be discouraged! If there's a problem with the implementation, hopefully you received feedback on what to improve. We're trying very hard to keep go-swagger lean and focused. We don't want it to do everything for everybody. This means that we might decide against incorporating a new feature. However, there might be a way to implement that feature *on top of* go-swagger. ### Conventions Fork the repo and make changes on your fork in a feature branch: - If it's a bugfix branch, name it XXX-something where XXX is the number of the issue - If it's a feature branch, create an enhancement issue to announce your intentions, and name it XXX-something where XXX is the number of the issue. Submit unit tests for your changes. Go has a great test framework built in; use it! Take a look at existing tests for inspiration. Run the full test suite on your branch before submitting a pull request. Update the documentation when creating or modifying features. Test your documentation changes for clarity, concision, and correctness, as well as a clean documentation build. See ``docs/README.md`` for more information on building the docs and how docs get released. Write clean code. Universally formatted code promotes ease of writing, reading, and maintenance. Always run `gofmt -s -w file.go` on each changed file before committing your changes. Most editors have plugins that do this automatically. Pull requests descriptions should be as clear as possible and include a reference to all the issues that they address. Pull requests must not contain commits from other users or branches. Commit messages must start with a capitalized and short summary (max. 50 chars) written in the imperative, followed by an optional, more detailed explanatory text which is separated from the summary by an empty line. Code review comments may be added to your pull request. Discuss, then make the suggested modifications and push additional commits to your feature branch. Be sure to post a comment after pushing. The new commits will show up in the pull request automatically, but the reviewers will not be notified unless you comment. Before the pull request is merged, make sure that you squash your commits into logical units of work using `git rebase -i` and `git push -f`. After every commit the test suite should be passing. Include documentation changes in the same commit so that a revert would remove all traces of the feature or fix. Commits that fix or close an issue should include a reference like `Closes #XXX` or `Fixes #XXX`, which will automatically close the issue when merged. ### Sign your work The sign-off is a simple line at the end of the explanation for the patch, which certifies that you wrote it or otherwise have the right to pass it on as an open-source patch. The rules are pretty simple: if you can certify the below (from [developercertificate.org](http://developercertificate.org/)): ``` Developer Certificate of Origin Version 1.1 Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 660 York Street, Suite 102, San Francisco, CA 94110 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Developer's Certificate of Origin 1.1 By making a contribution to this project, I certify that: (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. ``` then you just add a line to every git commit message: Signed-off-by: Joe Smith using your real name (sorry, no pseudonyms or anonymous contributions.) You can add the sign off when creating the git commit via `git commit -s`. golang-github-go-openapi-strfmt-0.19.0/.gitignore000066400000000000000000000000311344517625600217000ustar00rootroot00000000000000secrets.yml coverage.out golang-github-go-openapi-strfmt-0.19.0/.golangci.yml000066400000000000000000000007031344517625600223020ustar00rootroot00000000000000linters-settings: govet: check-shadowing: true golint: min-confidence: 0 gocyclo: min-complexity: 31 maligned: suggest-new: true dupl: threshold: 100 goconst: min-len: 2 min-occurrences: 4 linters: enable-all: true disable: - maligned - lll - gochecknoinits - gochecknoglobals issues: exclude-rules: - path: bson.go text: "should be .*ObjectID" linters: - golint golang-github-go-openapi-strfmt-0.19.0/.travis.yml000066400000000000000000000022011344517625600220220ustar00rootroot00000000000000after_success: - bash <(curl -s https://codecov.io/bash) go: - '1.9' - 1.10.x - 1.11.x install: - go get -u github.com/stretchr/testify/assert - go get -u github.com/google/uuid - go get -u github.com/asaskevich/govalidator - go get -u github.com/mailru/easyjson - go get -u github.com/go-openapi/errors - go get -u github.com/mitchellh/mapstructure - go get -u github.com/globalsign/mgo/bson language: go notifications: slack: secure: zE5AtIYTpYfQPnTzP+EaQPN7JKtfFAGv6PrJqoIZLOXa8B6zGb6+J1JRNNxWi7faWbyJOxa4FSSsuPsKZMycUK6wlLFIdhDxwqeo7Ew8r6rdZKdfUHQggfNS9wO79ARoNYUDHtmnaBUS+eWSM1YqSc4i99QxyyfuURLOeAaA/q14YbdlTlaw3lrZ0qT92ot1FnVGNOx064zuHtFeUf+jAVRMZ6Q3rvqllwIlPszE6rmHGXBt2VoJxRaBetdwd7FgkcYw9FPXKHhadwC7/75ZAdmxIukhxNMw4Tr5NuPcqNcnbYLenDP7B3lssGVIrP4BRSqekS1d/tqvdvnnFWHMwrNCkSnSc065G5+qWTlXKAemIclgiXXqE2furBNLm05MDdG8fn5epS0UNarkjD+zX336RiqwBlOX4KbF+vPyqcO98CsN0lnd+H6loc9reiTHs37orFFpQ+309av9be2GGsHUsRB9ssIyrewmhAccOmkRtr2dVTZJNFQwa5Kph5TNJuTjnZEwG/xUkEX2YSfwShOsb062JWiflV6PJdnl80pc9Tn7D5sO5Bf9DbijGRJwwP+YiiJtwtr+vsvS+n4sM0b5eqm4UoRo+JJO8ffoJtHS7ItuyRbVQCwEPJ4221WLcf5PquEEDdAPwR+K4Gj8qTXqTDdxOiES1xFUKVgmzhI= script: - ./hack/coverage golang-github-go-openapi-strfmt-0.19.0/CODE_OF_CONDUCT.md000066400000000000000000000062411344517625600225200ustar00rootroot00000000000000# Contributor Covenant Code of Conduct ## Our Pledge In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. ## Our Standards Examples of behavior that contributes to creating a positive environment include: * Using welcoming and inclusive language * Being respectful of differing viewpoints and experiences * Gracefully accepting constructive criticism * Focusing on what is best for the community * Showing empathy towards other community members Examples of unacceptable behavior by participants include: * The use of sexualized language or imagery and unwelcome sexual attention or advances * Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or electronic address, without explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. ## Scope This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at ivan+abuse@flanders.co.nz. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] [homepage]: http://contributor-covenant.org [version]: http://contributor-covenant.org/version/1/4/ golang-github-go-openapi-strfmt-0.19.0/LICENSE000066400000000000000000000261361344517625600207330ustar00rootroot00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. golang-github-go-openapi-strfmt-0.19.0/README.md000066400000000000000000000047111344517625600212000ustar00rootroot00000000000000# 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) [![license](http://img.shields.io/badge/license-Apache%20v2-orange.svg)](https://raw.githubusercontent.com/go-openapi/strfmt/master/LICENSE) [![GoDoc](https://godoc.org/github.com/go-openapi/strfmt?status.svg)](http://godoc.org/github.com/go-openapi/strfmt) [![GolangCI](https://golangci.com/badges/github.com/go-openapi/strfmt.svg)](https://golangci.com) [![Go Report Card](https://goreportcard.com/badge/github.com/go-openapi/strfmt)](https://goreportcard.com/report/github.com/go-openapi/strfmt) 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](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types). It also provides convenient extensions to go-openapi users. - [x] JSON-schema draft 4 formats - date-time - email - hostname - ipv4 - ipv6 - uri - [x] swagger 2.0 format extensions - binary - byte (e.g. base64 encoded string) - date (e.g. "1970-01-01") - password - [x] 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 - cidr (e.g. "192.0.2.1/24", "2001:db8:a0b:12f0::1/32") > 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 - CIDR - ISBN - ISBN10 - ISBN13 - MAC - ObjectId - Password - RGBColor - SSN - URI - UUID - UUID3 - UUID4 - UUID5 golang-github-go-openapi-strfmt-0.19.0/bson.go000066400000000000000000000072231344517625600212120ustar00rootroot00000000000000// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package strfmt import ( "database/sql/driver" "errors" "fmt" "github.com/globalsign/mgo/bson" "github.com/mailru/easyjson/jlexer" "github.com/mailru/easyjson/jwriter" ) func init() { var id ObjectId // register this format in the default registry Default.Add("bsonobjectid", &id, IsBSONObjectID) } // IsBSONObjectID returns true when the string is a valid BSON.ObjectId func IsBSONObjectID(str string) bool { return bson.IsObjectIdHex(str) } // ObjectId represents a BSON object ID (alias to github.com/globalsign/mgo/bson.ObjectId) // // swagger:strfmt bsonobjectid type ObjectId bson.ObjectId // NewObjectId creates a ObjectId from a Hex String func NewObjectId(hex string) ObjectId { return ObjectId(bson.ObjectIdHex(hex)) } // MarshalText turns this instance into text func (id *ObjectId) MarshalText() ([]byte, error) { return []byte(bson.ObjectId(*id).Hex()), nil } // UnmarshalText hydrates this instance from text func (id *ObjectId) UnmarshalText(data []byte) error { // validation is performed later on *id = ObjectId(bson.ObjectIdHex(string(data))) return nil } // Scan read a value from a database driver func (id *ObjectId) Scan(raw interface{}) error { var data []byte switch v := raw.(type) { case []byte: data = v case string: data = []byte(v) default: return fmt.Errorf("cannot sql.Scan() strfmt.URI from: %#v", v) } return id.UnmarshalText(data) } // Value converts a value to a database driver value func (id *ObjectId) Value() (driver.Value, error) { return driver.Value(string(*id)), nil } func (id *ObjectId) String() string { return string(*id) } // MarshalJSON returns the ObjectId as JSON func (id *ObjectId) MarshalJSON() ([]byte, error) { var w jwriter.Writer id.MarshalEasyJSON(&w) return w.BuildBytes() } // MarshalEasyJSON writes the ObjectId to a easyjson.Writer func (id *ObjectId) MarshalEasyJSON(w *jwriter.Writer) { w.String(bson.ObjectId(*id).Hex()) } // UnmarshalJSON sets the ObjectId from JSON func (id *ObjectId) UnmarshalJSON(data []byte) error { l := jlexer.Lexer{Data: data} id.UnmarshalEasyJSON(&l) return l.Error() } // UnmarshalEasyJSON sets the ObjectId from a easyjson.Lexer func (id *ObjectId) UnmarshalEasyJSON(in *jlexer.Lexer) { if data := in.String(); in.Ok() { *id = NewObjectId(data) } } // GetBSON returns the hex representation of the ObjectId as a bson.M{} map. func (id *ObjectId) GetBSON() (interface{}, error) { return bson.M{"data": bson.ObjectId(*id).Hex()}, nil } // SetBSON sets the ObjectId from raw bson data func (id *ObjectId) SetBSON(raw bson.Raw) error { var m bson.M if err := raw.Unmarshal(&m); err != nil { return err } if data, ok := m["data"].(string); ok { *id = NewObjectId(data) return nil } return errors.New("couldn't unmarshal bson raw value as ObjectId") } // DeepCopyInto copies the receiver and writes its value into out. func (id *ObjectId) DeepCopyInto(out *ObjectId) { *out = *id } // DeepCopy copies the receiver into a new ObjectId. func (id *ObjectId) DeepCopy() *ObjectId { if id == nil { return nil } out := new(ObjectId) id.DeepCopyInto(out) return out } golang-github-go-openapi-strfmt-0.19.0/bson_test.go000066400000000000000000000031751344517625600222530ustar00rootroot00000000000000// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package strfmt import ( "testing" "github.com/globalsign/mgo/bson" "github.com/stretchr/testify/assert" ) func TestBSONObjectId_fullCycle(t *testing.T) { id := NewObjectId("507f1f77bcf86cd799439011") bytes, err := id.MarshalText() assert.NoError(t, err) var idCopy ObjectId err = idCopy.Scan(bytes) assert.NoError(t, err) assert.Equal(t, id, idCopy) err = idCopy.UnmarshalText(bytes) assert.NoError(t, err) assert.Equal(t, id, idCopy) jsonBytes, err := id.MarshalJSON() assert.NoError(t, err) err = idCopy.UnmarshalJSON(jsonBytes) assert.NoError(t, err) assert.Equal(t, id, idCopy) bsonBytes, err := bson.Marshal(&id) assert.NoError(t, err) err = bson.Unmarshal(bsonBytes, &idCopy) assert.NoError(t, err) assert.Equal(t, id, idCopy) } func TestDeepCopyObjectId(t *testing.T) { id := NewObjectId("507f1f77bcf86cd799439011") in := &id out := new(ObjectId) in.DeepCopyInto(out) assert.Equal(t, in, out) out2 := in.DeepCopy() assert.Equal(t, in, out2) var inNil *ObjectId out3 := inNil.DeepCopy() assert.Nil(t, out3) } golang-github-go-openapi-strfmt-0.19.0/conv/000077500000000000000000000000001344517625600206635ustar00rootroot00000000000000golang-github-go-openapi-strfmt-0.19.0/conv/date.go000066400000000000000000000005651344517625600221350ustar00rootroot00000000000000package conv import "github.com/go-openapi/strfmt" // Date returns a pointer to of the Date value passed in. func Date(v strfmt.Date) *strfmt.Date { return &v } // DateValue returns the value of the Date pointer passed in or // the default value if the pointer is nil. func DateValue(v *strfmt.Date) strfmt.Date { if v == nil { return strfmt.Date{} } return *v } golang-github-go-openapi-strfmt-0.19.0/conv/date_test.go000066400000000000000000000004241344517625600231660ustar00rootroot00000000000000package conv import ( "testing" "time" "github.com/stretchr/testify/assert" "github.com/go-openapi/strfmt" ) func TestDateValue(t *testing.T) { assert.Equal(t, strfmt.Date{}, DateValue(nil)) date := strfmt.Date(time.Now()) assert.Equal(t, date, DateValue(&date)) } golang-github-go-openapi-strfmt-0.19.0/conv/default.go000066400000000000000000000152461344517625600226460ustar00rootroot00000000000000package conv import ( "github.com/go-openapi/strfmt" ) // Base64 returns a pointer to of the Base64 value passed in. func Base64(v strfmt.Base64) *strfmt.Base64 { return &v } // Base64Value returns the value of the Base64 pointer passed in or // the default value if the pointer is nil. func Base64Value(v *strfmt.Base64) strfmt.Base64 { if v == nil { return nil } return *v } // URI returns a pointer to of the URI value passed in. func URI(v strfmt.URI) *strfmt.URI { return &v } // URIValue returns the value of the URI pointer passed in or // the default value if the pointer is nil. func URIValue(v *strfmt.URI) strfmt.URI { if v == nil { return strfmt.URI("") } return *v } // Email returns a pointer to of the Email value passed in. func Email(v strfmt.Email) *strfmt.Email { return &v } // EmailValue returns the value of the Email pointer passed in or // the default value if the pointer is nil. func EmailValue(v *strfmt.Email) strfmt.Email { if v == nil { return strfmt.Email("") } return *v } // Hostname returns a pointer to of the Hostname value passed in. func Hostname(v strfmt.Hostname) *strfmt.Hostname { return &v } // HostnameValue returns the value of the Hostname pointer passed in or // the default value if the pointer is nil. func HostnameValue(v *strfmt.Hostname) strfmt.Hostname { if v == nil { return strfmt.Hostname("") } return *v } // IPv4 returns a pointer to of the IPv4 value passed in. func IPv4(v strfmt.IPv4) *strfmt.IPv4 { return &v } // IPv4Value returns the value of the IPv4 pointer passed in or // the default value if the pointer is nil. func IPv4Value(v *strfmt.IPv4) strfmt.IPv4 { if v == nil { return strfmt.IPv4("") } return *v } // IPv6 returns a pointer to of the IPv6 value passed in. func IPv6(v strfmt.IPv6) *strfmt.IPv6 { return &v } // IPv6Value returns the value of the IPv6 pointer passed in or // the default value if the pointer is nil. func IPv6Value(v *strfmt.IPv6) strfmt.IPv6 { if v == nil { return strfmt.IPv6("") } return *v } // CIDR returns a pointer to of the CIDR value passed in. func CIDR(v strfmt.CIDR) *strfmt.CIDR { return &v } // CIDRValue returns the value of the CIDR pointer passed in or // the default value if the pointer is nil. func CIDRValue(v *strfmt.CIDR) strfmt.CIDR { if v == nil { return strfmt.CIDR("") } return *v } // MAC returns a pointer to of the MAC value passed in. func MAC(v strfmt.MAC) *strfmt.MAC { return &v } // MACValue returns the value of the MAC pointer passed in or // the default value if the pointer is nil. func MACValue(v *strfmt.MAC) strfmt.MAC { if v == nil { return strfmt.MAC("") } return *v } // UUID returns a pointer to of the UUID value passed in. func UUID(v strfmt.UUID) *strfmt.UUID { return &v } // UUIDValue returns the value of the UUID pointer passed in or // the default value if the pointer is nil. func UUIDValue(v *strfmt.UUID) strfmt.UUID { if v == nil { return strfmt.UUID("") } return *v } // UUID3 returns a pointer to of the UUID3 value passed in. func UUID3(v strfmt.UUID3) *strfmt.UUID3 { return &v } // UUID3Value returns the value of the UUID3 pointer passed in or // the default value if the pointer is nil. func UUID3Value(v *strfmt.UUID3) strfmt.UUID3 { if v == nil { return strfmt.UUID3("") } return *v } // UUID4 returns a pointer to of the UUID4 value passed in. func UUID4(v strfmt.UUID4) *strfmt.UUID4 { return &v } // UUID4Value returns the value of the UUID4 pointer passed in or // the default value if the pointer is nil. func UUID4Value(v *strfmt.UUID4) strfmt.UUID4 { if v == nil { return strfmt.UUID4("") } return *v } // UUID5 returns a pointer to of the UUID5 value passed in. func UUID5(v strfmt.UUID5) *strfmt.UUID5 { return &v } // UUID5Value returns the value of the UUID5 pointer passed in or // the default value if the pointer is nil. func UUID5Value(v *strfmt.UUID5) strfmt.UUID5 { if v == nil { return strfmt.UUID5("") } return *v } // ISBN returns a pointer to of the ISBN value passed in. func ISBN(v strfmt.ISBN) *strfmt.ISBN { return &v } // ISBNValue returns the value of the ISBN pointer passed in or // the default value if the pointer is nil. func ISBNValue(v *strfmt.ISBN) strfmt.ISBN { if v == nil { return strfmt.ISBN("") } return *v } // ISBN10 returns a pointer to of the ISBN10 value passed in. func ISBN10(v strfmt.ISBN10) *strfmt.ISBN10 { return &v } // ISBN10Value returns the value of the ISBN10 pointer passed in or // the default value if the pointer is nil. func ISBN10Value(v *strfmt.ISBN10) strfmt.ISBN10 { if v == nil { return strfmt.ISBN10("") } return *v } // ISBN13 returns a pointer to of the ISBN13 value passed in. func ISBN13(v strfmt.ISBN13) *strfmt.ISBN13 { return &v } // ISBN13Value returns the value of the ISBN13 pointer passed in or // the default value if the pointer is nil. func ISBN13Value(v *strfmt.ISBN13) strfmt.ISBN13 { if v == nil { return strfmt.ISBN13("") } return *v } // CreditCard returns a pointer to of the CreditCard value passed in. func CreditCard(v strfmt.CreditCard) *strfmt.CreditCard { return &v } // CreditCardValue returns the value of the CreditCard pointer passed in or // the default value if the pointer is nil. func CreditCardValue(v *strfmt.CreditCard) strfmt.CreditCard { if v == nil { return strfmt.CreditCard("") } return *v } // SSN returns a pointer to of the SSN value passed in. func SSN(v strfmt.SSN) *strfmt.SSN { return &v } // SSNValue returns the value of the SSN pointer passed in or // the default value if the pointer is nil. func SSNValue(v *strfmt.SSN) strfmt.SSN { if v == nil { return strfmt.SSN("") } return *v } // HexColor returns a pointer to of the HexColor value passed in. func HexColor(v strfmt.HexColor) *strfmt.HexColor { return &v } // HexColorValue returns the value of the HexColor pointer passed in or // the default value if the pointer is nil. func HexColorValue(v *strfmt.HexColor) strfmt.HexColor { if v == nil { return strfmt.HexColor("") } return *v } // RGBColor returns a pointer to of the RGBColor value passed in. func RGBColor(v strfmt.RGBColor) *strfmt.RGBColor { return &v } // RGBColorValue returns the value of the RGBColor pointer passed in or // the default value if the pointer is nil. func RGBColorValue(v *strfmt.RGBColor) strfmt.RGBColor { if v == nil { return strfmt.RGBColor("") } return *v } // Password returns a pointer to of the Password value passed in. func Password(v strfmt.Password) *strfmt.Password { return &v } // PasswordValue returns the value of the Password pointer passed in or // the default value if the pointer is nil. func PasswordValue(v *strfmt.Password) strfmt.Password { if v == nil { return strfmt.Password("") } return *v } golang-github-go-openapi-strfmt-0.19.0/conv/default_test.go000066400000000000000000000066101344517625600237000ustar00rootroot00000000000000package conv import ( "testing" "github.com/stretchr/testify/assert" "github.com/go-openapi/strfmt" ) func TestBase64Value(t *testing.T) { assert.Equal(t, strfmt.Base64(nil), Base64Value(nil)) base64 := strfmt.Base64([]byte{4, 2}) assert.Equal(t, base64, Base64Value(&base64)) } func TestURIValue(t *testing.T) { assert.Equal(t, strfmt.URI(""), URIValue(nil)) value := strfmt.URI("foo") assert.Equal(t, value, URIValue(&value)) } func TestEmailValue(t *testing.T) { assert.Equal(t, strfmt.Email(""), EmailValue(nil)) value := strfmt.Email("foo") assert.Equal(t, value, EmailValue(&value)) } func TestHostnameValue(t *testing.T) { assert.Equal(t, strfmt.Hostname(""), HostnameValue(nil)) value := strfmt.Hostname("foo") assert.Equal(t, value, HostnameValue(&value)) } func TestIPv4Value(t *testing.T) { assert.Equal(t, strfmt.IPv4(""), IPv4Value(nil)) value := strfmt.IPv4("foo") assert.Equal(t, value, IPv4Value(&value)) } func TestIPv6Value(t *testing.T) { assert.Equal(t, strfmt.IPv6(""), IPv6Value(nil)) value := strfmt.IPv6("foo") assert.Equal(t, value, IPv6Value(&value)) } func TestCIDRValue(t *testing.T) { assert.Equal(t, strfmt.CIDR(""), CIDRValue(nil)) value := strfmt.CIDR("foo") assert.Equal(t, value, CIDRValue(&value)) } func TestMACValue(t *testing.T) { assert.Equal(t, strfmt.MAC(""), MACValue(nil)) value := strfmt.MAC("foo") assert.Equal(t, value, MACValue(&value)) } func TestUUIDValue(t *testing.T) { assert.Equal(t, strfmt.UUID(""), UUIDValue(nil)) value := strfmt.UUID("foo") assert.Equal(t, value, UUIDValue(&value)) } func TestUUID3Value(t *testing.T) { assert.Equal(t, strfmt.UUID3(""), UUID3Value(nil)) value := strfmt.UUID3("foo") assert.Equal(t, value, UUID3Value(&value)) } func TestUUID4Value(t *testing.T) { assert.Equal(t, strfmt.UUID4(""), UUID4Value(nil)) value := strfmt.UUID4("foo") assert.Equal(t, value, UUID4Value(&value)) } func TestUUID5Value(t *testing.T) { assert.Equal(t, strfmt.UUID5(""), UUID5Value(nil)) value := strfmt.UUID5("foo") assert.Equal(t, value, UUID5Value(&value)) } func TestISBNValue(t *testing.T) { assert.Equal(t, strfmt.ISBN(""), ISBNValue(nil)) value := strfmt.ISBN("foo") assert.Equal(t, value, ISBNValue(&value)) } func TestISBN10Value(t *testing.T) { assert.Equal(t, strfmt.ISBN10(""), ISBN10Value(nil)) value := strfmt.ISBN10("foo") assert.Equal(t, value, ISBN10Value(&value)) } func TestISBN13Value(t *testing.T) { assert.Equal(t, strfmt.ISBN13(""), ISBN13Value(nil)) value := strfmt.ISBN13("foo") assert.Equal(t, value, ISBN13Value(&value)) } func TestCreditCardValue(t *testing.T) { assert.Equal(t, strfmt.CreditCard(""), CreditCardValue(nil)) value := strfmt.CreditCard("foo") assert.Equal(t, value, CreditCardValue(&value)) } func TestSSNValue(t *testing.T) { assert.Equal(t, strfmt.SSN(""), SSNValue(nil)) value := strfmt.SSN("foo") assert.Equal(t, value, SSNValue(&value)) } func TestHexColorValue(t *testing.T) { assert.Equal(t, strfmt.HexColor(""), HexColorValue(nil)) value := strfmt.HexColor("foo") assert.Equal(t, value, HexColorValue(&value)) } func TestRGBColorValue(t *testing.T) { assert.Equal(t, strfmt.RGBColor(""), RGBColorValue(nil)) value := strfmt.RGBColor("foo") assert.Equal(t, value, RGBColorValue(&value)) } func TestPasswordValue(t *testing.T) { assert.Equal(t, strfmt.Password(""), PasswordValue(nil)) value := strfmt.Password("foo") assert.Equal(t, value, PasswordValue(&value)) } golang-github-go-openapi-strfmt-0.19.0/conv/duration.go000066400000000000000000000006421344517625600230410ustar00rootroot00000000000000package conv import "github.com/go-openapi/strfmt" // Duration returns a pointer to of the Duration value passed in. func Duration(v strfmt.Duration) *strfmt.Duration { return &v } // DurationValue returns the value of the Duration pointer passed in or // the default value if the pointer is nil. func DurationValue(v *strfmt.Duration) strfmt.Duration { if v == nil { return strfmt.Duration(0) } return *v } golang-github-go-openapi-strfmt-0.19.0/conv/duration_test.go000066400000000000000000000004451344517625600241010ustar00rootroot00000000000000package conv import ( "testing" "github.com/stretchr/testify/assert" "github.com/go-openapi/strfmt" ) func TestDurationValue(t *testing.T) { assert.Equal(t, strfmt.Duration(0), DurationValue(nil)) duration := strfmt.Duration(42) assert.Equal(t, duration, DurationValue(&duration)) } golang-github-go-openapi-strfmt-0.19.0/conv/time.go000066400000000000000000000006411344517625600221510ustar00rootroot00000000000000package conv import "github.com/go-openapi/strfmt" // DateTime returns a pointer to of the DateTime value passed in. func DateTime(v strfmt.DateTime) *strfmt.DateTime { return &v } // DateTimeValue returns the value of the DateTime pointer passed in or // the default value if the pointer is nil. func DateTimeValue(v *strfmt.DateTime) strfmt.DateTime { if v == nil { return strfmt.DateTime{} } return *v } golang-github-go-openapi-strfmt-0.19.0/conv/time_test.go000066400000000000000000000004501344517625600232060ustar00rootroot00000000000000package conv import ( "testing" "time" "github.com/stretchr/testify/assert" "github.com/go-openapi/strfmt" ) func TestDateTimeValue(t *testing.T) { assert.Equal(t, strfmt.DateTime{}, DateTimeValue(nil)) time := strfmt.DateTime(time.Now()) assert.Equal(t, time, DateTimeValue(&time)) } golang-github-go-openapi-strfmt-0.19.0/date.go000066400000000000000000000075141344517625600211710ustar00rootroot00000000000000// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package strfmt import ( "database/sql/driver" "errors" "fmt" "time" "github.com/globalsign/mgo/bson" "github.com/mailru/easyjson/jlexer" "github.com/mailru/easyjson/jwriter" ) func init() { d := Date{} // register this format in the default registry Default.Add("date", &d, IsDate) } // IsDate returns true when the string is a valid date func IsDate(str string) bool { _, err := time.Parse(RFC3339FullDate, str) return err == nil } const ( // RFC3339FullDate represents a full-date as specified by RFC3339 // See: http://goo.gl/xXOvVd RFC3339FullDate = "2006-01-02" ) // Date represents a date from the API // // swagger:strfmt date type Date time.Time // String converts this date into a string func (d Date) String() string { return time.Time(d).Format(RFC3339FullDate) } // UnmarshalText parses a text representation into a date type func (d *Date) UnmarshalText(text []byte) error { if len(text) == 0 { return nil } dd, err := time.Parse(RFC3339FullDate, string(text)) if err != nil { return err } *d = Date(dd) return nil } // MarshalText serializes this date type to string func (d Date) MarshalText() ([]byte, error) { return []byte(d.String()), nil } // Scan scans a Date value from database driver type. func (d *Date) Scan(raw interface{}) error { switch v := raw.(type) { case []byte: return d.UnmarshalText(v) case string: return d.UnmarshalText([]byte(v)) case time.Time: *d = Date(v) return nil case nil: *d = Date{} return nil default: return fmt.Errorf("cannot sql.Scan() strfmt.Date from: %#v", v) } } // Value converts Date to a primitive value ready to written to a database. func (d Date) Value() (driver.Value, error) { return driver.Value(d.String()), nil } // MarshalJSON returns the Date as JSON func (d Date) MarshalJSON() ([]byte, error) { var w jwriter.Writer d.MarshalEasyJSON(&w) return w.BuildBytes() } // MarshalEasyJSON writes the Date to a easyjson.Writer func (d Date) MarshalEasyJSON(w *jwriter.Writer) { w.String(time.Time(d).Format(RFC3339FullDate)) } // UnmarshalJSON sets the Date from JSON func (d *Date) UnmarshalJSON(data []byte) error { if string(data) == jsonNull { return nil } l := jlexer.Lexer{Data: data} d.UnmarshalEasyJSON(&l) return l.Error() } // UnmarshalEasyJSON sets the Date from a easyjson.Lexer func (d *Date) UnmarshalEasyJSON(in *jlexer.Lexer) { if data := in.String(); in.Ok() { tt, err := time.Parse(RFC3339FullDate, data) if err != nil { in.AddError(err) return } *d = Date(tt) } } // GetBSON returns the Date as a bson.M{} map. func (d *Date) GetBSON() (interface{}, error) { return bson.M{"data": d.String()}, nil } // SetBSON sets the Date from raw bson data func (d *Date) SetBSON(raw bson.Raw) error { var m bson.M if err := raw.Unmarshal(&m); err != nil { return err } if data, ok := m["data"].(string); ok { rd, err := time.Parse(RFC3339FullDate, data) *d = Date(rd) return err } return errors.New("couldn't unmarshal bson raw value as Date") } // DeepCopyInto copies the receiver and writes its value into out. func (d *Date) DeepCopyInto(out *Date) { *out = *d } // DeepCopy copies the receiver into a new Date. func (d *Date) DeepCopy() *Date { if d == nil { return nil } out := new(Date) d.DeepCopyInto(out) return out } golang-github-go-openapi-strfmt-0.19.0/date_test.go000066400000000000000000000070451344517625600222270ustar00rootroot00000000000000// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package strfmt import ( "database/sql" "database/sql/driver" "testing" "time" "github.com/globalsign/mgo/bson" "github.com/stretchr/testify/assert" ) var _ sql.Scanner = &Date{} var _ driver.Valuer = Date{} func TestDate(t *testing.T) { pp := Date{} err := pp.UnmarshalText([]byte{}) assert.NoError(t, err) err = pp.UnmarshalText([]byte("yada")) assert.Error(t, err) orig := "2014-12-15" bj := []byte("\"" + orig + "\"") err = pp.UnmarshalText([]byte(orig)) assert.NoError(t, err) txt, err := pp.MarshalText() assert.NoError(t, err) assert.Equal(t, orig, string(txt)) err = pp.UnmarshalJSON(bj) assert.NoError(t, err) assert.EqualValues(t, orig, pp.String()) err = pp.UnmarshalJSON([]byte(`"1972/01/01"`)) assert.Error(t, err) b, err := pp.MarshalJSON() assert.NoError(t, err) assert.Equal(t, bj, b) dateOriginal := Date(time.Date(2014, 10, 10, 0, 0, 0, 0, time.UTC)) bsonData, err := bson.Marshal(&dateOriginal) assert.NoError(t, err) var dateCopy Date err = bson.Unmarshal(bsonData, &dateCopy) assert.NoError(t, err) assert.Equal(t, dateOriginal, dateCopy) var dateZero Date err = dateZero.UnmarshalJSON([]byte(jsonNull)) assert.NoError(t, err) assert.Equal(t, Date{}, dateZero) } func TestDate_Scan(t *testing.T) { ref := time.Now().Truncate(24 * time.Hour).UTC() date, str := Date(ref), ref.Format(RFC3339FullDate) values := []interface{}{str, []byte(str), ref} for _, value := range values { result := Date{} _ = (&result).Scan(value) assert.Equal(t, date, result, "value: %#v", value) } dd := Date{} err := dd.Scan(nil) assert.NoError(t, err) assert.Equal(t, Date{}, dd) err = dd.Scan(19700101) assert.Error(t, err) } func TestDate_Value(t *testing.T) { ref := time.Now().Truncate(24 * time.Hour).UTC() date := Date(ref) dbv, err := date.Value() assert.NoError(t, err) assert.EqualValues(t, dbv, ref.Format("2006-01-02")) } func TestDate_IsDate(t *testing.T) { tests := []struct { value string valid bool }{ {"2017-12-22", true}, {"2017-1-1", false}, {"17-13-22", false}, {"2017-02-29", false}, // not a valid date : 2017 is not a leap year {"1900-02-29", false}, // not a valid date : 1900 is not a leap year {"2100-02-29", false}, // not a valid date : 2100 is not a leap year {"2000-02-29", true}, // a valid date : 2000 is a leap year {"2400-02-29", true}, // a valid date : 2000 is a leap year {"2017-13-22", false}, {"2017-12-32", false}, {"20171-12-32", false}, {"YYYY-MM-DD", false}, {"20-17-2017", false}, {"2017-12-22T01:02:03Z", false}, } for _, test := range tests { assert.Equal(t, test.valid, IsDate(test.value), "value [%s] should be valid: [%t]", test.value, test.valid) } } func TestDeepCopyDate(t *testing.T) { ref := time.Now().Truncate(24 * time.Hour).UTC() date := Date(ref) in := &date out := new(Date) in.DeepCopyInto(out) assert.Equal(t, in, out) out2 := in.DeepCopy() assert.Equal(t, in, out2) var inNil *Date out3 := inNil.DeepCopy() assert.Nil(t, out3) } golang-github-go-openapi-strfmt-0.19.0/default.go000066400000000000000000001465421344517625600217050ustar00rootroot00000000000000// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package strfmt import ( "database/sql/driver" "encoding/base64" "errors" "fmt" "net/mail" "regexp" "strings" "github.com/asaskevich/govalidator" "github.com/globalsign/mgo/bson" "github.com/mailru/easyjson/jlexer" "github.com/mailru/easyjson/jwriter" ) 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 // ::= any one of the ten digits 0 through 9 // var digit = /[0-9]/; // ::= 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]/; // ::= | // var letDig = /[0-9a-zA-Z]/; // ::= | "-" // var letDigHyp = /[-0-9a-zA-Z]/; // ::= | // var ldhStr = /[-0-9a-zA-Z]+/; //