podman
2035 строк · 46.0 Кб
1// Copyright 2015 go-swagger maintainers
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package strfmt16
17import (18"database/sql/driver"19"encoding/base64"20"encoding/json"21"errors"22"fmt"23"net/mail"24"regexp"25"strings"26
27"github.com/asaskevich/govalidator"28"go.mongodb.org/mongo-driver/bson"29)
30
31const (32// HostnamePattern http://json-schema.org/latest/json-schema-validation.html#anchor11433// A string instance is valid against this attribute if it is a valid34// representation for an Internet host name, as defined by RFC 1034, section 3.1 [RFC1034].35// http://tools.ietf.org/html/rfc1034#section-3.536// <digit> ::= any one of the ten digits 0 through 937// var digit = /[0-9]/;38// <letter> ::= any one of the 52 alphabetic characters A through Z in upper case and a through z in lower case39// var letter = /[a-zA-Z]/;40// <let-dig> ::= <letter> | <digit>41// var letDig = /[0-9a-zA-Z]/;42// <let-dig-hyp> ::= <let-dig> | "-"43// var letDigHyp = /[-0-9a-zA-Z]/;44// <ldh-str> ::= <let-dig-hyp> | <let-dig-hyp> <ldh-str>45// var ldhStr = /[-0-9a-zA-Z]+/;46// <label> ::= <letter> [ [ <ldh-str> ] <let-dig> ]47// var label = /[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?/;48// <subdomain> ::= <label> | <subdomain> "." <label>49// var subdomain = /^[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?(\.[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?)*$/;50// <domain> ::= <subdomain> | " "51//52// Additional validations:53// - for FDQNs, top-level domain (e.g. ".com"), is at least to letters long (no special characters here)54// - hostnames may start with a digit [RFC1123]55// - special registered names with an underscore ('_') are not allowed in this context56// - dashes are permitted, but not at the start or the end of a segment57// - long top-level domain names (e.g. example.london) are permitted58// - symbol unicode points are permitted (e.g. emoji) (not for top-level domain)59HostnamePattern = `^([a-zA-Z0-9\p{S}\p{L}]((-?[a-zA-Z0-9\p{S}\p{L}]{0,62})?)|([a-zA-Z0-9\p{S}\p{L}](([a-zA-Z0-9-\p{S}\p{L}]{0,61}[a-zA-Z0-9\p{S}\p{L}])?)(\.)){1,}([a-zA-Z\p{L}]){2,63})$`60// UUIDPattern Regex for UUID that allows uppercase61UUIDPattern = `(?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}$`62// UUID3Pattern Regex for UUID3 that allows uppercase63UUID3Pattern = `(?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?3[0-9a-f]{3}-?[0-9a-f]{4}-?[0-9a-f]{12}$`64// UUID4Pattern Regex for UUID4 that allows uppercase65UUID4Pattern = `(?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?4[0-9a-f]{3}-?[89ab][0-9a-f]{3}-?[0-9a-f]{12}$`66// UUID5Pattern Regex for UUID5 that allows uppercase67UUID5Pattern = `(?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?5[0-9a-f]{3}-?[89ab][0-9a-f]{3}-?[0-9a-f]{12}$`68// json null type69jsonNull = "null"70)
71
72var (73rxHostname = regexp.MustCompile(HostnamePattern)74rxUUID = regexp.MustCompile(UUIDPattern)75rxUUID3 = regexp.MustCompile(UUID3Pattern)76rxUUID4 = regexp.MustCompile(UUID4Pattern)77rxUUID5 = regexp.MustCompile(UUID5Pattern)78)
79
80// IsHostname returns true when the string is a valid hostname
81func IsHostname(str string) bool {82if !rxHostname.MatchString(str) {83return false84}85
86// the sum of all label octets and label lengths is limited to 255.87if len(str) > 255 {88return false89}90
91// Each node has a label, which is zero to 63 octets in length92parts := strings.Split(str, ".")93valid := true94for _, p := range parts {95if len(p) > 63 {96valid = false97}98}99return valid100}
101
102// IsUUID returns true is the string matches a UUID, upper case is allowed
103func IsUUID(str string) bool {104return rxUUID.MatchString(str)105}
106
107// IsUUID3 returns true is the string matches a UUID, upper case is allowed
108func IsUUID3(str string) bool {109return rxUUID3.MatchString(str)110}
111
112// IsUUID4 returns true is the string matches a UUID, upper case is allowed
113func IsUUID4(str string) bool {114return rxUUID4.MatchString(str)115}
116
117// IsUUID5 returns true is the string matches a UUID, upper case is allowed
118func IsUUID5(str string) bool {119return rxUUID5.MatchString(str)120}
121
122// IsEmail validates an email address.
123func IsEmail(str string) bool {124addr, e := mail.ParseAddress(str)125return e == nil && addr.Address != ""126}
127
128func init() {129// register formats in the default registry:130// - byte131// - creditcard132133// - hexcolor134// - hostname135// - ipv4136// - ipv6137// - cidr138// - isbn139// - isbn10140// - isbn13141// - mac142// - password143// - rgbcolor144// - ssn145// - uri146// - uuid147// - uuid3148// - uuid4149// - uuid5150u := URI("")151Default.Add("uri", &u, govalidator.IsRequestURI)152
153eml := Email("")154Default.Add("email", &eml, IsEmail)155
156hn := Hostname("")157Default.Add("hostname", &hn, IsHostname)158
159ip4 := IPv4("")160Default.Add("ipv4", &ip4, govalidator.IsIPv4)161
162ip6 := IPv6("")163Default.Add("ipv6", &ip6, govalidator.IsIPv6)164
165cidr := CIDR("")166Default.Add("cidr", &cidr, govalidator.IsCIDR)167
168mac := MAC("")169Default.Add("mac", &mac, govalidator.IsMAC)170
171uid := UUID("")172Default.Add("uuid", &uid, IsUUID)173
174uid3 := UUID3("")175Default.Add("uuid3", &uid3, IsUUID3)176
177uid4 := UUID4("")178Default.Add("uuid4", &uid4, IsUUID4)179
180uid5 := UUID5("")181Default.Add("uuid5", &uid5, IsUUID5)182
183isbn := ISBN("")184Default.Add("isbn", &isbn, func(str string) bool { return govalidator.IsISBN10(str) || govalidator.IsISBN13(str) })185
186isbn10 := ISBN10("")187Default.Add("isbn10", &isbn10, govalidator.IsISBN10)188
189isbn13 := ISBN13("")190Default.Add("isbn13", &isbn13, govalidator.IsISBN13)191
192cc := CreditCard("")193Default.Add("creditcard", &cc, govalidator.IsCreditCard)194
195ssn := SSN("")196Default.Add("ssn", &ssn, govalidator.IsSSN)197
198hc := HexColor("")199Default.Add("hexcolor", &hc, govalidator.IsHexcolor)200
201rc := RGBColor("")202Default.Add("rgbcolor", &rc, govalidator.IsRGBcolor)203
204b64 := Base64([]byte(nil))205Default.Add("byte", &b64, govalidator.IsBase64)206
207pw := Password("")208Default.Add("password", &pw, func(_ string) bool { return true })209}
210
211// Base64 represents a base64 encoded string, using URLEncoding alphabet
212//
213// swagger:strfmt byte
214type Base64 []byte215
216// MarshalText turns this instance into text
217func (b Base64) MarshalText() ([]byte, error) {218enc := base64.URLEncoding219src := []byte(b)220buf := make([]byte, enc.EncodedLen(len(src)))221enc.Encode(buf, src)222return buf, nil223}
224
225// UnmarshalText hydrates this instance from text
226func (b *Base64) UnmarshalText(data []byte) error { // validation is performed later on227enc := base64.URLEncoding228dbuf := make([]byte, enc.DecodedLen(len(data)))229
230n, err := enc.Decode(dbuf, data)231if err != nil {232return err233}234
235*b = dbuf[:n]236return nil237}
238
239// Scan read a value from a database driver
240func (b *Base64) Scan(raw interface{}) error {241switch v := raw.(type) {242case []byte:243dbuf := make([]byte, base64.StdEncoding.DecodedLen(len(v)))244n, err := base64.StdEncoding.Decode(dbuf, v)245if err != nil {246return err247}248*b = dbuf[:n]249case string:250vv, err := base64.StdEncoding.DecodeString(v)251if err != nil {252return err253}254*b = Base64(vv)255default:256return fmt.Errorf("cannot sql.Scan() strfmt.Base64 from: %#v", v)257}258
259return nil260}
261
262// Value converts a value to a database driver value
263func (b Base64) Value() (driver.Value, error) {264return driver.Value(b.String()), nil265}
266
267func (b Base64) String() string {268return base64.StdEncoding.EncodeToString([]byte(b))269}
270
271// MarshalJSON returns the Base64 as JSON
272func (b Base64) MarshalJSON() ([]byte, error) {273return json.Marshal(b.String())274}
275
276// UnmarshalJSON sets the Base64 from JSON
277func (b *Base64) UnmarshalJSON(data []byte) error {278var b64str string279if err := json.Unmarshal(data, &b64str); err != nil {280return err281}282vb, err := base64.StdEncoding.DecodeString(b64str)283if err != nil {284return err285}286*b = Base64(vb)287return nil288}
289
290// MarshalBSON document from this value
291func (b Base64) MarshalBSON() ([]byte, error) {292return bson.Marshal(bson.M{"data": b.String()})293}
294
295// UnmarshalBSON document into this value
296func (b *Base64) UnmarshalBSON(data []byte) error {297var m bson.M298if err := bson.Unmarshal(data, &m); err != nil {299return err300}301
302if bd, ok := m["data"].(string); ok {303vb, err := base64.StdEncoding.DecodeString(bd)304if err != nil {305return err306}307*b = Base64(vb)308return nil309}310return errors.New("couldn't unmarshal bson bytes as base64")311}
312
313// DeepCopyInto copies the receiver and writes its value into out.
314func (b *Base64) DeepCopyInto(out *Base64) {315*out = *b316}
317
318// DeepCopy copies the receiver into a new Base64.
319func (b *Base64) DeepCopy() *Base64 {320if b == nil {321return nil322}323out := new(Base64)324b.DeepCopyInto(out)325return out326}
327
328// URI represents the uri string format as specified by the json schema spec
329//
330// swagger:strfmt uri
331type URI string332
333// MarshalText turns this instance into text
334func (u URI) MarshalText() ([]byte, error) {335return []byte(string(u)), nil336}
337
338// UnmarshalText hydrates this instance from text
339func (u *URI) UnmarshalText(data []byte) error { // validation is performed later on340*u = URI(string(data))341return nil342}
343
344// Scan read a value from a database driver
345func (u *URI) Scan(raw interface{}) error {346switch v := raw.(type) {347case []byte:348*u = URI(string(v))349case string:350*u = URI(v)351default:352return fmt.Errorf("cannot sql.Scan() strfmt.URI from: %#v", v)353}354
355return nil356}
357
358// Value converts a value to a database driver value
359func (u URI) Value() (driver.Value, error) {360return driver.Value(string(u)), nil361}
362
363func (u URI) String() string {364return string(u)365}
366
367// MarshalJSON returns the URI as JSON
368func (u URI) MarshalJSON() ([]byte, error) {369return json.Marshal(string(u))370}
371
372// UnmarshalJSON sets the URI from JSON
373func (u *URI) UnmarshalJSON(data []byte) error {374var uristr string375if err := json.Unmarshal(data, &uristr); err != nil {376return err377}378*u = URI(uristr)379return nil380}
381
382// MarshalBSON document from this value
383func (u URI) MarshalBSON() ([]byte, error) {384return bson.Marshal(bson.M{"data": u.String()})385}
386
387// UnmarshalBSON document into this value
388func (u *URI) UnmarshalBSON(data []byte) error {389var m bson.M390if err := bson.Unmarshal(data, &m); err != nil {391return err392}393
394if ud, ok := m["data"].(string); ok {395*u = URI(ud)396return nil397}398return errors.New("couldn't unmarshal bson bytes as uri")399}
400
401// DeepCopyInto copies the receiver and writes its value into out.
402func (u *URI) DeepCopyInto(out *URI) {403*out = *u404}
405
406// DeepCopy copies the receiver into a new URI.
407func (u *URI) DeepCopy() *URI {408if u == nil {409return nil410}411out := new(URI)412u.DeepCopyInto(out)413return out414}
415
416// Email represents the email string format as specified by the json schema spec
417//
418// swagger:strfmt email
419type Email string420
421// MarshalText turns this instance into text
422func (e Email) MarshalText() ([]byte, error) {423return []byte(string(e)), nil424}
425
426// UnmarshalText hydrates this instance from text
427func (e *Email) UnmarshalText(data []byte) error { // validation is performed later on428*e = Email(string(data))429return nil430}
431
432// Scan read a value from a database driver
433func (e *Email) Scan(raw interface{}) error {434switch v := raw.(type) {435case []byte:436*e = Email(string(v))437case string:438*e = Email(v)439default:440return fmt.Errorf("cannot sql.Scan() strfmt.Email from: %#v", v)441}442
443return nil444}
445
446// Value converts a value to a database driver value
447func (e Email) Value() (driver.Value, error) {448return driver.Value(string(e)), nil449}
450
451func (e Email) String() string {452return string(e)453}
454
455// MarshalJSON returns the Email as JSON
456func (e Email) MarshalJSON() ([]byte, error) {457return json.Marshal(string(e))458}
459
460// UnmarshalJSON sets the Email from JSON
461func (e *Email) UnmarshalJSON(data []byte) error {462var estr string463if err := json.Unmarshal(data, &estr); err != nil {464return err465}466*e = Email(estr)467return nil468}
469
470// MarshalBSON document from this value
471func (e Email) MarshalBSON() ([]byte, error) {472return bson.Marshal(bson.M{"data": e.String()})473}
474
475// UnmarshalBSON document into this value
476func (e *Email) UnmarshalBSON(data []byte) error {477var m bson.M478if err := bson.Unmarshal(data, &m); err != nil {479return err480}481
482if ud, ok := m["data"].(string); ok {483*e = Email(ud)484return nil485}486return errors.New("couldn't unmarshal bson bytes as email")487}
488
489// DeepCopyInto copies the receiver and writes its value into out.
490func (e *Email) DeepCopyInto(out *Email) {491*out = *e492}
493
494// DeepCopy copies the receiver into a new Email.
495func (e *Email) DeepCopy() *Email {496if e == nil {497return nil498}499out := new(Email)500e.DeepCopyInto(out)501return out502}
503
504// Hostname represents the hostname string format as specified by the json schema spec
505//
506// swagger:strfmt hostname
507type Hostname string508
509// MarshalText turns this instance into text
510func (h Hostname) MarshalText() ([]byte, error) {511return []byte(string(h)), nil512}
513
514// UnmarshalText hydrates this instance from text
515func (h *Hostname) UnmarshalText(data []byte) error { // validation is performed later on516*h = Hostname(string(data))517return nil518}
519
520// Scan read a value from a database driver
521func (h *Hostname) Scan(raw interface{}) error {522switch v := raw.(type) {523case []byte:524*h = Hostname(string(v))525case string:526*h = Hostname(v)527default:528return fmt.Errorf("cannot sql.Scan() strfmt.Hostname from: %#v", v)529}530
531return nil532}
533
534// Value converts a value to a database driver value
535func (h Hostname) Value() (driver.Value, error) {536return driver.Value(string(h)), nil537}
538
539func (h Hostname) String() string {540return string(h)541}
542
543// MarshalJSON returns the Hostname as JSON
544func (h Hostname) MarshalJSON() ([]byte, error) {545return json.Marshal(string(h))546}
547
548// UnmarshalJSON sets the Hostname from JSON
549func (h *Hostname) UnmarshalJSON(data []byte) error {550var hstr string551if err := json.Unmarshal(data, &hstr); err != nil {552return err553}554*h = Hostname(hstr)555return nil556}
557
558// MarshalBSON document from this value
559func (h Hostname) MarshalBSON() ([]byte, error) {560return bson.Marshal(bson.M{"data": h.String()})561}
562
563// UnmarshalBSON document into this value
564func (h *Hostname) UnmarshalBSON(data []byte) error {565var m bson.M566if err := bson.Unmarshal(data, &m); err != nil {567return err568}569
570if ud, ok := m["data"].(string); ok {571*h = Hostname(ud)572return nil573}574return errors.New("couldn't unmarshal bson bytes as hostname")575}
576
577// DeepCopyInto copies the receiver and writes its value into out.
578func (h *Hostname) DeepCopyInto(out *Hostname) {579*out = *h580}
581
582// DeepCopy copies the receiver into a new Hostname.
583func (h *Hostname) DeepCopy() *Hostname {584if h == nil {585return nil586}587out := new(Hostname)588h.DeepCopyInto(out)589return out590}
591
592// IPv4 represents an IP v4 address
593//
594// swagger:strfmt ipv4
595type IPv4 string596
597// MarshalText turns this instance into text
598func (u IPv4) MarshalText() ([]byte, error) {599return []byte(string(u)), nil600}
601
602// UnmarshalText hydrates this instance from text
603func (u *IPv4) UnmarshalText(data []byte) error { // validation is performed later on604*u = IPv4(string(data))605return nil606}
607
608// Scan read a value from a database driver
609func (u *IPv4) Scan(raw interface{}) error {610switch v := raw.(type) {611case []byte:612*u = IPv4(string(v))613case string:614*u = IPv4(v)615default:616return fmt.Errorf("cannot sql.Scan() strfmt.IPv4 from: %#v", v)617}618
619return nil620}
621
622// Value converts a value to a database driver value
623func (u IPv4) Value() (driver.Value, error) {624return driver.Value(string(u)), nil625}
626
627func (u IPv4) String() string {628return string(u)629}
630
631// MarshalJSON returns the IPv4 as JSON
632func (u IPv4) MarshalJSON() ([]byte, error) {633return json.Marshal(string(u))634}
635
636// UnmarshalJSON sets the IPv4 from JSON
637func (u *IPv4) UnmarshalJSON(data []byte) error {638var ustr string639if err := json.Unmarshal(data, &ustr); err != nil {640return err641}642*u = IPv4(ustr)643return nil644}
645
646// MarshalBSON document from this value
647func (u IPv4) MarshalBSON() ([]byte, error) {648return bson.Marshal(bson.M{"data": u.String()})649}
650
651// UnmarshalBSON document into this value
652func (u *IPv4) UnmarshalBSON(data []byte) error {653var m bson.M654if err := bson.Unmarshal(data, &m); err != nil {655return err656}657
658if ud, ok := m["data"].(string); ok {659*u = IPv4(ud)660return nil661}662return errors.New("couldn't unmarshal bson bytes as ipv4")663}
664
665// DeepCopyInto copies the receiver and writes its value into out.
666func (u *IPv4) DeepCopyInto(out *IPv4) {667*out = *u668}
669
670// DeepCopy copies the receiver into a new IPv4.
671func (u *IPv4) DeepCopy() *IPv4 {672if u == nil {673return nil674}675out := new(IPv4)676u.DeepCopyInto(out)677return out678}
679
680// IPv6 represents an IP v6 address
681//
682// swagger:strfmt ipv6
683type IPv6 string684
685// MarshalText turns this instance into text
686func (u IPv6) MarshalText() ([]byte, error) {687return []byte(string(u)), nil688}
689
690// UnmarshalText hydrates this instance from text
691func (u *IPv6) UnmarshalText(data []byte) error { // validation is performed later on692*u = IPv6(string(data))693return nil694}
695
696// Scan read a value from a database driver
697func (u *IPv6) Scan(raw interface{}) error {698switch v := raw.(type) {699case []byte:700*u = IPv6(string(v))701case string:702*u = IPv6(v)703default:704return fmt.Errorf("cannot sql.Scan() strfmt.IPv6 from: %#v", v)705}706
707return nil708}
709
710// Value converts a value to a database driver value
711func (u IPv6) Value() (driver.Value, error) {712return driver.Value(string(u)), nil713}
714
715func (u IPv6) String() string {716return string(u)717}
718
719// MarshalJSON returns the IPv6 as JSON
720func (u IPv6) MarshalJSON() ([]byte, error) {721return json.Marshal(string(u))722}
723
724// UnmarshalJSON sets the IPv6 from JSON
725func (u *IPv6) UnmarshalJSON(data []byte) error {726var ustr string727if err := json.Unmarshal(data, &ustr); err != nil {728return err729}730*u = IPv6(ustr)731return nil732}
733
734// MarshalBSON document from this value
735func (u IPv6) MarshalBSON() ([]byte, error) {736return bson.Marshal(bson.M{"data": u.String()})737}
738
739// UnmarshalBSON document into this value
740func (u *IPv6) UnmarshalBSON(data []byte) error {741var m bson.M742if err := bson.Unmarshal(data, &m); err != nil {743return err744}745
746if ud, ok := m["data"].(string); ok {747*u = IPv6(ud)748return nil749}750return errors.New("couldn't unmarshal bson bytes as ipv6")751}
752
753// DeepCopyInto copies the receiver and writes its value into out.
754func (u *IPv6) DeepCopyInto(out *IPv6) {755*out = *u756}
757
758// DeepCopy copies the receiver into a new IPv6.
759func (u *IPv6) DeepCopy() *IPv6 {760if u == nil {761return nil762}763out := new(IPv6)764u.DeepCopyInto(out)765return out766}
767
768// CIDR represents a Classless Inter-Domain Routing notation
769//
770// swagger:strfmt cidr
771type CIDR string772
773// MarshalText turns this instance into text
774func (u CIDR) MarshalText() ([]byte, error) {775return []byte(string(u)), nil776}
777
778// UnmarshalText hydrates this instance from text
779func (u *CIDR) UnmarshalText(data []byte) error { // validation is performed later on780*u = CIDR(string(data))781return nil782}
783
784// Scan read a value from a database driver
785func (u *CIDR) Scan(raw interface{}) error {786switch v := raw.(type) {787case []byte:788*u = CIDR(string(v))789case string:790*u = CIDR(v)791default:792return fmt.Errorf("cannot sql.Scan() strfmt.CIDR from: %#v", v)793}794
795return nil796}
797
798// Value converts a value to a database driver value
799func (u CIDR) Value() (driver.Value, error) {800return driver.Value(string(u)), nil801}
802
803func (u CIDR) String() string {804return string(u)805}
806
807// MarshalJSON returns the CIDR as JSON
808func (u CIDR) MarshalJSON() ([]byte, error) {809return json.Marshal(string(u))810}
811
812// UnmarshalJSON sets the CIDR from JSON
813func (u *CIDR) UnmarshalJSON(data []byte) error {814var ustr string815if err := json.Unmarshal(data, &ustr); err != nil {816return err817}818*u = CIDR(ustr)819return nil820}
821
822// MarshalBSON document from this value
823func (u CIDR) MarshalBSON() ([]byte, error) {824return bson.Marshal(bson.M{"data": u.String()})825}
826
827// UnmarshalBSON document into this value
828func (u *CIDR) UnmarshalBSON(data []byte) error {829var m bson.M830if err := bson.Unmarshal(data, &m); err != nil {831return err832}833
834if ud, ok := m["data"].(string); ok {835*u = CIDR(ud)836return nil837}838return errors.New("couldn't unmarshal bson bytes as CIDR")839}
840
841// DeepCopyInto copies the receiver and writes its value into out.
842func (u *CIDR) DeepCopyInto(out *CIDR) {843*out = *u844}
845
846// DeepCopy copies the receiver into a new CIDR.
847func (u *CIDR) DeepCopy() *CIDR {848if u == nil {849return nil850}851out := new(CIDR)852u.DeepCopyInto(out)853return out854}
855
856// MAC represents a 48 bit MAC address
857//
858// swagger:strfmt mac
859type MAC string860
861// MarshalText turns this instance into text
862func (u MAC) MarshalText() ([]byte, error) {863return []byte(string(u)), nil864}
865
866// UnmarshalText hydrates this instance from text
867func (u *MAC) UnmarshalText(data []byte) error { // validation is performed later on868*u = MAC(string(data))869return nil870}
871
872// Scan read a value from a database driver
873func (u *MAC) Scan(raw interface{}) error {874switch v := raw.(type) {875case []byte:876*u = MAC(string(v))877case string:878*u = MAC(v)879default:880return fmt.Errorf("cannot sql.Scan() strfmt.IPv4 from: %#v", v)881}882
883return nil884}
885
886// Value converts a value to a database driver value
887func (u MAC) Value() (driver.Value, error) {888return driver.Value(string(u)), nil889}
890
891func (u MAC) String() string {892return string(u)893}
894
895// MarshalJSON returns the MAC as JSON
896func (u MAC) MarshalJSON() ([]byte, error) {897return json.Marshal(string(u))898}
899
900// UnmarshalJSON sets the MAC from JSON
901func (u *MAC) UnmarshalJSON(data []byte) error {902var ustr string903if err := json.Unmarshal(data, &ustr); err != nil {904return err905}906*u = MAC(ustr)907return nil908}
909
910// MarshalBSON document from this value
911func (u MAC) MarshalBSON() ([]byte, error) {912return bson.Marshal(bson.M{"data": u.String()})913}
914
915// UnmarshalBSON document into this value
916func (u *MAC) UnmarshalBSON(data []byte) error {917var m bson.M918if err := bson.Unmarshal(data, &m); err != nil {919return err920}921
922if ud, ok := m["data"].(string); ok {923*u = MAC(ud)924return nil925}926return errors.New("couldn't unmarshal bson bytes as MAC")927}
928
929// DeepCopyInto copies the receiver and writes its value into out.
930func (u *MAC) DeepCopyInto(out *MAC) {931*out = *u932}
933
934// DeepCopy copies the receiver into a new MAC.
935func (u *MAC) DeepCopy() *MAC {936if u == nil {937return nil938}939out := new(MAC)940u.DeepCopyInto(out)941return out942}
943
944// UUID represents a uuid string format
945//
946// swagger:strfmt uuid
947type UUID string948
949// MarshalText turns this instance into text
950func (u UUID) MarshalText() ([]byte, error) {951return []byte(string(u)), nil952}
953
954// UnmarshalText hydrates this instance from text
955func (u *UUID) UnmarshalText(data []byte) error { // validation is performed later on956*u = UUID(string(data))957return nil958}
959
960// Scan read a value from a database driver
961func (u *UUID) Scan(raw interface{}) error {962switch v := raw.(type) {963case []byte:964*u = UUID(string(v))965case string:966*u = UUID(v)967default:968return fmt.Errorf("cannot sql.Scan() strfmt.UUID from: %#v", v)969}970
971return nil972}
973
974// Value converts a value to a database driver value
975func (u UUID) Value() (driver.Value, error) {976return driver.Value(string(u)), nil977}
978
979func (u UUID) String() string {980return string(u)981}
982
983// MarshalJSON returns the UUID as JSON
984func (u UUID) MarshalJSON() ([]byte, error) {985return json.Marshal(string(u))986}
987
988// UnmarshalJSON sets the UUID from JSON
989func (u *UUID) UnmarshalJSON(data []byte) error {990if string(data) == jsonNull {991return nil992}993var ustr string994if err := json.Unmarshal(data, &ustr); err != nil {995return err996}997*u = UUID(ustr)998return nil999}
1000
1001// MarshalBSON document from this value
1002func (u UUID) MarshalBSON() ([]byte, error) {1003return bson.Marshal(bson.M{"data": u.String()})1004}
1005
1006// UnmarshalBSON document into this value
1007func (u *UUID) UnmarshalBSON(data []byte) error {1008var m bson.M1009if err := bson.Unmarshal(data, &m); err != nil {1010return err1011}1012
1013if ud, ok := m["data"].(string); ok {1014*u = UUID(ud)1015return nil1016}1017return errors.New("couldn't unmarshal bson bytes as UUID")1018}
1019
1020// DeepCopyInto copies the receiver and writes its value into out.
1021func (u *UUID) DeepCopyInto(out *UUID) {1022*out = *u1023}
1024
1025// DeepCopy copies the receiver into a new UUID.
1026func (u *UUID) DeepCopy() *UUID {1027if u == nil {1028return nil1029}1030out := new(UUID)1031u.DeepCopyInto(out)1032return out1033}
1034
1035// UUID3 represents a uuid3 string format
1036//
1037// swagger:strfmt uuid3
1038type UUID3 string1039
1040// MarshalText turns this instance into text
1041func (u UUID3) MarshalText() ([]byte, error) {1042return []byte(string(u)), nil1043}
1044
1045// UnmarshalText hydrates this instance from text
1046func (u *UUID3) UnmarshalText(data []byte) error { // validation is performed later on1047*u = UUID3(string(data))1048return nil1049}
1050
1051// Scan read a value from a database driver
1052func (u *UUID3) Scan(raw interface{}) error {1053switch v := raw.(type) {1054case []byte:1055*u = UUID3(string(v))1056case string:1057*u = UUID3(v)1058default:1059return fmt.Errorf("cannot sql.Scan() strfmt.UUID3 from: %#v", v)1060}1061
1062return nil1063}
1064
1065// Value converts a value to a database driver value
1066func (u UUID3) Value() (driver.Value, error) {1067return driver.Value(string(u)), nil1068}
1069
1070func (u UUID3) String() string {1071return string(u)1072}
1073
1074// MarshalJSON returns the UUID as JSON
1075func (u UUID3) MarshalJSON() ([]byte, error) {1076return json.Marshal(string(u))1077}
1078
1079// UnmarshalJSON sets the UUID from JSON
1080func (u *UUID3) UnmarshalJSON(data []byte) error {1081if string(data) == jsonNull {1082return nil1083}1084var ustr string1085if err := json.Unmarshal(data, &ustr); err != nil {1086return err1087}1088*u = UUID3(ustr)1089return nil1090}
1091
1092// MarshalBSON document from this value
1093func (u UUID3) MarshalBSON() ([]byte, error) {1094return bson.Marshal(bson.M{"data": u.String()})1095}
1096
1097// UnmarshalBSON document into this value
1098func (u *UUID3) UnmarshalBSON(data []byte) error {1099var m bson.M1100if err := bson.Unmarshal(data, &m); err != nil {1101return err1102}1103
1104if ud, ok := m["data"].(string); ok {1105*u = UUID3(ud)1106return nil1107}1108return errors.New("couldn't unmarshal bson bytes as UUID3")1109}
1110
1111// DeepCopyInto copies the receiver and writes its value into out.
1112func (u *UUID3) DeepCopyInto(out *UUID3) {1113*out = *u1114}
1115
1116// DeepCopy copies the receiver into a new UUID3.
1117func (u *UUID3) DeepCopy() *UUID3 {1118if u == nil {1119return nil1120}1121out := new(UUID3)1122u.DeepCopyInto(out)1123return out1124}
1125
1126// UUID4 represents a uuid4 string format
1127//
1128// swagger:strfmt uuid4
1129type UUID4 string1130
1131// MarshalText turns this instance into text
1132func (u UUID4) MarshalText() ([]byte, error) {1133return []byte(string(u)), nil1134}
1135
1136// UnmarshalText hydrates this instance from text
1137func (u *UUID4) UnmarshalText(data []byte) error { // validation is performed later on1138*u = UUID4(string(data))1139return nil1140}
1141
1142// Scan read a value from a database driver
1143func (u *UUID4) Scan(raw interface{}) error {1144switch v := raw.(type) {1145case []byte:1146*u = UUID4(string(v))1147case string:1148*u = UUID4(v)1149default:1150return fmt.Errorf("cannot sql.Scan() strfmt.UUID4 from: %#v", v)1151}1152
1153return nil1154}
1155
1156// Value converts a value to a database driver value
1157func (u UUID4) Value() (driver.Value, error) {1158return driver.Value(string(u)), nil1159}
1160
1161func (u UUID4) String() string {1162return string(u)1163}
1164
1165// MarshalJSON returns the UUID as JSON
1166func (u UUID4) MarshalJSON() ([]byte, error) {1167return json.Marshal(string(u))1168}
1169
1170// UnmarshalJSON sets the UUID from JSON
1171func (u *UUID4) UnmarshalJSON(data []byte) error {1172if string(data) == jsonNull {1173return nil1174}1175var ustr string1176if err := json.Unmarshal(data, &ustr); err != nil {1177return err1178}1179*u = UUID4(ustr)1180return nil1181}
1182
1183// MarshalBSON document from this value
1184func (u UUID4) MarshalBSON() ([]byte, error) {1185return bson.Marshal(bson.M{"data": u.String()})1186}
1187
1188// UnmarshalBSON document into this value
1189func (u *UUID4) UnmarshalBSON(data []byte) error {1190var m bson.M1191if err := bson.Unmarshal(data, &m); err != nil {1192return err1193}1194
1195if ud, ok := m["data"].(string); ok {1196*u = UUID4(ud)1197return nil1198}1199return errors.New("couldn't unmarshal bson bytes as UUID4")1200}
1201
1202// DeepCopyInto copies the receiver and writes its value into out.
1203func (u *UUID4) DeepCopyInto(out *UUID4) {1204*out = *u1205}
1206
1207// DeepCopy copies the receiver into a new UUID4.
1208func (u *UUID4) DeepCopy() *UUID4 {1209if u == nil {1210return nil1211}1212out := new(UUID4)1213u.DeepCopyInto(out)1214return out1215}
1216
1217// UUID5 represents a uuid5 string format
1218//
1219// swagger:strfmt uuid5
1220type UUID5 string1221
1222// MarshalText turns this instance into text
1223func (u UUID5) MarshalText() ([]byte, error) {1224return []byte(string(u)), nil1225}
1226
1227// UnmarshalText hydrates this instance from text
1228func (u *UUID5) UnmarshalText(data []byte) error { // validation is performed later on1229*u = UUID5(string(data))1230return nil1231}
1232
1233// Scan read a value from a database driver
1234func (u *UUID5) Scan(raw interface{}) error {1235switch v := raw.(type) {1236case []byte:1237*u = UUID5(string(v))1238case string:1239*u = UUID5(v)1240default:1241return fmt.Errorf("cannot sql.Scan() strfmt.UUID5 from: %#v", v)1242}1243
1244return nil1245}
1246
1247// Value converts a value to a database driver value
1248func (u UUID5) Value() (driver.Value, error) {1249return driver.Value(string(u)), nil1250}
1251
1252func (u UUID5) String() string {1253return string(u)1254}
1255
1256// MarshalJSON returns the UUID as JSON
1257func (u UUID5) MarshalJSON() ([]byte, error) {1258return json.Marshal(string(u))1259}
1260
1261// UnmarshalJSON sets the UUID from JSON
1262func (u *UUID5) UnmarshalJSON(data []byte) error {1263if string(data) == jsonNull {1264return nil1265}1266var ustr string1267if err := json.Unmarshal(data, &ustr); err != nil {1268return err1269}1270*u = UUID5(ustr)1271return nil1272}
1273
1274// MarshalBSON document from this value
1275func (u UUID5) MarshalBSON() ([]byte, error) {1276return bson.Marshal(bson.M{"data": u.String()})1277}
1278
1279// UnmarshalBSON document into this value
1280func (u *UUID5) UnmarshalBSON(data []byte) error {1281var m bson.M1282if err := bson.Unmarshal(data, &m); err != nil {1283return err1284}1285
1286if ud, ok := m["data"].(string); ok {1287*u = UUID5(ud)1288return nil1289}1290return errors.New("couldn't unmarshal bson bytes as UUID5")1291}
1292
1293// DeepCopyInto copies the receiver and writes its value into out.
1294func (u *UUID5) DeepCopyInto(out *UUID5) {1295*out = *u1296}
1297
1298// DeepCopy copies the receiver into a new UUID5.
1299func (u *UUID5) DeepCopy() *UUID5 {1300if u == nil {1301return nil1302}1303out := new(UUID5)1304u.DeepCopyInto(out)1305return out1306}
1307
1308// ISBN represents an isbn string format
1309//
1310// swagger:strfmt isbn
1311type ISBN string1312
1313// MarshalText turns this instance into text
1314func (u ISBN) MarshalText() ([]byte, error) {1315return []byte(string(u)), nil1316}
1317
1318// UnmarshalText hydrates this instance from text
1319func (u *ISBN) UnmarshalText(data []byte) error { // validation is performed later on1320*u = ISBN(string(data))1321return nil1322}
1323
1324// Scan read a value from a database driver
1325func (u *ISBN) Scan(raw interface{}) error {1326switch v := raw.(type) {1327case []byte:1328*u = ISBN(string(v))1329case string:1330*u = ISBN(v)1331default:1332return fmt.Errorf("cannot sql.Scan() strfmt.ISBN from: %#v", v)1333}1334
1335return nil1336}
1337
1338// Value converts a value to a database driver value
1339func (u ISBN) Value() (driver.Value, error) {1340return driver.Value(string(u)), nil1341}
1342
1343func (u ISBN) String() string {1344return string(u)1345}
1346
1347// MarshalJSON returns the ISBN as JSON
1348func (u ISBN) MarshalJSON() ([]byte, error) {1349return json.Marshal(string(u))1350}
1351
1352// UnmarshalJSON sets the ISBN from JSON
1353func (u *ISBN) UnmarshalJSON(data []byte) error {1354if string(data) == jsonNull {1355return nil1356}1357var ustr string1358if err := json.Unmarshal(data, &ustr); err != nil {1359return err1360}1361*u = ISBN(ustr)1362return nil1363}
1364
1365// MarshalBSON document from this value
1366func (u ISBN) MarshalBSON() ([]byte, error) {1367return bson.Marshal(bson.M{"data": u.String()})1368}
1369
1370// UnmarshalBSON document into this value
1371func (u *ISBN) UnmarshalBSON(data []byte) error {1372var m bson.M1373if err := bson.Unmarshal(data, &m); err != nil {1374return err1375}1376
1377if ud, ok := m["data"].(string); ok {1378*u = ISBN(ud)1379return nil1380}1381return errors.New("couldn't unmarshal bson bytes as ISBN")1382}
1383
1384// DeepCopyInto copies the receiver and writes its value into out.
1385func (u *ISBN) DeepCopyInto(out *ISBN) {1386*out = *u1387}
1388
1389// DeepCopy copies the receiver into a new ISBN.
1390func (u *ISBN) DeepCopy() *ISBN {1391if u == nil {1392return nil1393}1394out := new(ISBN)1395u.DeepCopyInto(out)1396return out1397}
1398
1399// ISBN10 represents an isbn 10 string format
1400//
1401// swagger:strfmt isbn10
1402type ISBN10 string1403
1404// MarshalText turns this instance into text
1405func (u ISBN10) MarshalText() ([]byte, error) {1406return []byte(string(u)), nil1407}
1408
1409// UnmarshalText hydrates this instance from text
1410func (u *ISBN10) UnmarshalText(data []byte) error { // validation is performed later on1411*u = ISBN10(string(data))1412return nil1413}
1414
1415// Scan read a value from a database driver
1416func (u *ISBN10) Scan(raw interface{}) error {1417switch v := raw.(type) {1418case []byte:1419*u = ISBN10(string(v))1420case string:1421*u = ISBN10(v)1422default:1423return fmt.Errorf("cannot sql.Scan() strfmt.ISBN10 from: %#v", v)1424}1425
1426return nil1427}
1428
1429// Value converts a value to a database driver value
1430func (u ISBN10) Value() (driver.Value, error) {1431return driver.Value(string(u)), nil1432}
1433
1434func (u ISBN10) String() string {1435return string(u)1436}
1437
1438// MarshalJSON returns the ISBN10 as JSON
1439func (u ISBN10) MarshalJSON() ([]byte, error) {1440return json.Marshal(string(u))1441}
1442
1443// UnmarshalJSON sets the ISBN10 from JSON
1444func (u *ISBN10) UnmarshalJSON(data []byte) error {1445if string(data) == jsonNull {1446return nil1447}1448var ustr string1449if err := json.Unmarshal(data, &ustr); err != nil {1450return err1451}1452*u = ISBN10(ustr)1453return nil1454}
1455
1456// MarshalBSON document from this value
1457func (u ISBN10) MarshalBSON() ([]byte, error) {1458return bson.Marshal(bson.M{"data": u.String()})1459}
1460
1461// UnmarshalBSON document into this value
1462func (u *ISBN10) UnmarshalBSON(data []byte) error {1463var m bson.M1464if err := bson.Unmarshal(data, &m); err != nil {1465return err1466}1467
1468if ud, ok := m["data"].(string); ok {1469*u = ISBN10(ud)1470return nil1471}1472return errors.New("couldn't unmarshal bson bytes as ISBN10")1473}
1474
1475// DeepCopyInto copies the receiver and writes its value into out.
1476func (u *ISBN10) DeepCopyInto(out *ISBN10) {1477*out = *u1478}
1479
1480// DeepCopy copies the receiver into a new ISBN10.
1481func (u *ISBN10) DeepCopy() *ISBN10 {1482if u == nil {1483return nil1484}1485out := new(ISBN10)1486u.DeepCopyInto(out)1487return out1488}
1489
1490// ISBN13 represents an isbn 13 string format
1491//
1492// swagger:strfmt isbn13
1493type ISBN13 string1494
1495// MarshalText turns this instance into text
1496func (u ISBN13) MarshalText() ([]byte, error) {1497return []byte(string(u)), nil1498}
1499
1500// UnmarshalText hydrates this instance from text
1501func (u *ISBN13) UnmarshalText(data []byte) error { // validation is performed later on1502*u = ISBN13(string(data))1503return nil1504}
1505
1506// Scan read a value from a database driver
1507func (u *ISBN13) Scan(raw interface{}) error {1508switch v := raw.(type) {1509case []byte:1510*u = ISBN13(string(v))1511case string:1512*u = ISBN13(v)1513default:1514return fmt.Errorf("cannot sql.Scan() strfmt.ISBN13 from: %#v", v)1515}1516
1517return nil1518}
1519
1520// Value converts a value to a database driver value
1521func (u ISBN13) Value() (driver.Value, error) {1522return driver.Value(string(u)), nil1523}
1524
1525func (u ISBN13) String() string {1526return string(u)1527}
1528
1529// MarshalJSON returns the ISBN13 as JSON
1530func (u ISBN13) MarshalJSON() ([]byte, error) {1531return json.Marshal(string(u))1532}
1533
1534// UnmarshalJSON sets the ISBN13 from JSON
1535func (u *ISBN13) UnmarshalJSON(data []byte) error {1536if string(data) == jsonNull {1537return nil1538}1539var ustr string1540if err := json.Unmarshal(data, &ustr); err != nil {1541return err1542}1543*u = ISBN13(ustr)1544return nil1545}
1546
1547// MarshalBSON document from this value
1548func (u ISBN13) MarshalBSON() ([]byte, error) {1549return bson.Marshal(bson.M{"data": u.String()})1550}
1551
1552// UnmarshalBSON document into this value
1553func (u *ISBN13) UnmarshalBSON(data []byte) error {1554var m bson.M1555if err := bson.Unmarshal(data, &m); err != nil {1556return err1557}1558
1559if ud, ok := m["data"].(string); ok {1560*u = ISBN13(ud)1561return nil1562}1563return errors.New("couldn't unmarshal bson bytes as ISBN13")1564}
1565
1566// DeepCopyInto copies the receiver and writes its value into out.
1567func (u *ISBN13) DeepCopyInto(out *ISBN13) {1568*out = *u1569}
1570
1571// DeepCopy copies the receiver into a new ISBN13.
1572func (u *ISBN13) DeepCopy() *ISBN13 {1573if u == nil {1574return nil1575}1576out := new(ISBN13)1577u.DeepCopyInto(out)1578return out1579}
1580
1581// CreditCard represents a credit card string format
1582//
1583// swagger:strfmt creditcard
1584type CreditCard string1585
1586// MarshalText turns this instance into text
1587func (u CreditCard) MarshalText() ([]byte, error) {1588return []byte(string(u)), nil1589}
1590
1591// UnmarshalText hydrates this instance from text
1592func (u *CreditCard) UnmarshalText(data []byte) error { // validation is performed later on1593*u = CreditCard(string(data))1594return nil1595}
1596
1597// Scan read a value from a database driver
1598func (u *CreditCard) Scan(raw interface{}) error {1599switch v := raw.(type) {1600case []byte:1601*u = CreditCard(string(v))1602case string:1603*u = CreditCard(v)1604default:1605return fmt.Errorf("cannot sql.Scan() strfmt.CreditCard from: %#v", v)1606}1607
1608return nil1609}
1610
1611// Value converts a value to a database driver value
1612func (u CreditCard) Value() (driver.Value, error) {1613return driver.Value(string(u)), nil1614}
1615
1616func (u CreditCard) String() string {1617return string(u)1618}
1619
1620// MarshalJSON returns the CreditCard as JSON
1621func (u CreditCard) MarshalJSON() ([]byte, error) {1622return json.Marshal(string(u))1623}
1624
1625// UnmarshalJSON sets the CreditCard from JSON
1626func (u *CreditCard) UnmarshalJSON(data []byte) error {1627if string(data) == jsonNull {1628return nil1629}1630var ustr string1631if err := json.Unmarshal(data, &ustr); err != nil {1632return err1633}1634*u = CreditCard(ustr)1635return nil1636}
1637
1638// MarshalBSON document from this value
1639func (u CreditCard) MarshalBSON() ([]byte, error) {1640return bson.Marshal(bson.M{"data": u.String()})1641}
1642
1643// UnmarshalBSON document into this value
1644func (u *CreditCard) UnmarshalBSON(data []byte) error {1645var m bson.M1646if err := bson.Unmarshal(data, &m); err != nil {1647return err1648}1649
1650if ud, ok := m["data"].(string); ok {1651*u = CreditCard(ud)1652return nil1653}1654return errors.New("couldn't unmarshal bson bytes as CreditCard")1655}
1656
1657// DeepCopyInto copies the receiver and writes its value into out.
1658func (u *CreditCard) DeepCopyInto(out *CreditCard) {1659*out = *u1660}
1661
1662// DeepCopy copies the receiver into a new CreditCard.
1663func (u *CreditCard) DeepCopy() *CreditCard {1664if u == nil {1665return nil1666}1667out := new(CreditCard)1668u.DeepCopyInto(out)1669return out1670}
1671
1672// SSN represents a social security string format
1673//
1674// swagger:strfmt ssn
1675type SSN string1676
1677// MarshalText turns this instance into text
1678func (u SSN) MarshalText() ([]byte, error) {1679return []byte(string(u)), nil1680}
1681
1682// UnmarshalText hydrates this instance from text
1683func (u *SSN) UnmarshalText(data []byte) error { // validation is performed later on1684*u = SSN(string(data))1685return nil1686}
1687
1688// Scan read a value from a database driver
1689func (u *SSN) Scan(raw interface{}) error {1690switch v := raw.(type) {1691case []byte:1692*u = SSN(string(v))1693case string:1694*u = SSN(v)1695default:1696return fmt.Errorf("cannot sql.Scan() strfmt.SSN from: %#v", v)1697}1698
1699return nil1700}
1701
1702// Value converts a value to a database driver value
1703func (u SSN) Value() (driver.Value, error) {1704return driver.Value(string(u)), nil1705}
1706
1707func (u SSN) String() string {1708return string(u)1709}
1710
1711// MarshalJSON returns the SSN as JSON
1712func (u SSN) MarshalJSON() ([]byte, error) {1713return json.Marshal(string(u))1714}
1715
1716// UnmarshalJSON sets the SSN from JSON
1717func (u *SSN) UnmarshalJSON(data []byte) error {1718if string(data) == jsonNull {1719return nil1720}1721var ustr string1722if err := json.Unmarshal(data, &ustr); err != nil {1723return err1724}1725*u = SSN(ustr)1726return nil1727}
1728
1729// MarshalBSON document from this value
1730func (u SSN) MarshalBSON() ([]byte, error) {1731return bson.Marshal(bson.M{"data": u.String()})1732}
1733
1734// UnmarshalBSON document into this value
1735func (u *SSN) UnmarshalBSON(data []byte) error {1736var m bson.M1737if err := bson.Unmarshal(data, &m); err != nil {1738return err1739}1740
1741if ud, ok := m["data"].(string); ok {1742*u = SSN(ud)1743return nil1744}1745return errors.New("couldn't unmarshal bson bytes as SSN")1746}
1747
1748// DeepCopyInto copies the receiver and writes its value into out.
1749func (u *SSN) DeepCopyInto(out *SSN) {1750*out = *u1751}
1752
1753// DeepCopy copies the receiver into a new SSN.
1754func (u *SSN) DeepCopy() *SSN {1755if u == nil {1756return nil1757}1758out := new(SSN)1759u.DeepCopyInto(out)1760return out1761}
1762
1763// HexColor represents a hex color string format
1764//
1765// swagger:strfmt hexcolor
1766type HexColor string1767
1768// MarshalText turns this instance into text
1769func (h HexColor) MarshalText() ([]byte, error) {1770return []byte(string(h)), nil1771}
1772
1773// UnmarshalText hydrates this instance from text
1774func (h *HexColor) UnmarshalText(data []byte) error { // validation is performed later on1775*h = HexColor(string(data))1776return nil1777}
1778
1779// Scan read a value from a database driver
1780func (h *HexColor) Scan(raw interface{}) error {1781switch v := raw.(type) {1782case []byte:1783*h = HexColor(string(v))1784case string:1785*h = HexColor(v)1786default:1787return fmt.Errorf("cannot sql.Scan() strfmt.HexColor from: %#v", v)1788}1789
1790return nil1791}
1792
1793// Value converts a value to a database driver value
1794func (h HexColor) Value() (driver.Value, error) {1795return driver.Value(string(h)), nil1796}
1797
1798func (h HexColor) String() string {1799return string(h)1800}
1801
1802// MarshalJSON returns the HexColor as JSON
1803func (h HexColor) MarshalJSON() ([]byte, error) {1804return json.Marshal(string(h))1805}
1806
1807// UnmarshalJSON sets the HexColor from JSON
1808func (h *HexColor) UnmarshalJSON(data []byte) error {1809if string(data) == jsonNull {1810return nil1811}1812var ustr string1813if err := json.Unmarshal(data, &ustr); err != nil {1814return err1815}1816*h = HexColor(ustr)1817return nil1818}
1819
1820// MarshalBSON document from this value
1821func (h HexColor) MarshalBSON() ([]byte, error) {1822return bson.Marshal(bson.M{"data": h.String()})1823}
1824
1825// UnmarshalBSON document into this value
1826func (h *HexColor) UnmarshalBSON(data []byte) error {1827var m bson.M1828if err := bson.Unmarshal(data, &m); err != nil {1829return err1830}1831
1832if ud, ok := m["data"].(string); ok {1833*h = HexColor(ud)1834return nil1835}1836return errors.New("couldn't unmarshal bson bytes as HexColor")1837}
1838
1839// DeepCopyInto copies the receiver and writes its value into out.
1840func (h *HexColor) DeepCopyInto(out *HexColor) {1841*out = *h1842}
1843
1844// DeepCopy copies the receiver into a new HexColor.
1845func (h *HexColor) DeepCopy() *HexColor {1846if h == nil {1847return nil1848}1849out := new(HexColor)1850h.DeepCopyInto(out)1851return out1852}
1853
1854// RGBColor represents a RGB color string format
1855//
1856// swagger:strfmt rgbcolor
1857type RGBColor string1858
1859// MarshalText turns this instance into text
1860func (r RGBColor) MarshalText() ([]byte, error) {1861return []byte(string(r)), nil1862}
1863
1864// UnmarshalText hydrates this instance from text
1865func (r *RGBColor) UnmarshalText(data []byte) error { // validation is performed later on1866*r = RGBColor(string(data))1867return nil1868}
1869
1870// Scan read a value from a database driver
1871func (r *RGBColor) Scan(raw interface{}) error {1872switch v := raw.(type) {1873case []byte:1874*r = RGBColor(string(v))1875case string:1876*r = RGBColor(v)1877default:1878return fmt.Errorf("cannot sql.Scan() strfmt.RGBColor from: %#v", v)1879}1880
1881return nil1882}
1883
1884// Value converts a value to a database driver value
1885func (r RGBColor) Value() (driver.Value, error) {1886return driver.Value(string(r)), nil1887}
1888
1889func (r RGBColor) String() string {1890return string(r)1891}
1892
1893// MarshalJSON returns the RGBColor as JSON
1894func (r RGBColor) MarshalJSON() ([]byte, error) {1895return json.Marshal(string(r))1896}
1897
1898// UnmarshalJSON sets the RGBColor from JSON
1899func (r *RGBColor) UnmarshalJSON(data []byte) error {1900if string(data) == jsonNull {1901return nil1902}1903var ustr string1904if err := json.Unmarshal(data, &ustr); err != nil {1905return err1906}1907*r = RGBColor(ustr)1908return nil1909}
1910
1911// MarshalBSON document from this value
1912func (r RGBColor) MarshalBSON() ([]byte, error) {1913return bson.Marshal(bson.M{"data": r.String()})1914}
1915
1916// UnmarshalBSON document into this value
1917func (r *RGBColor) UnmarshalBSON(data []byte) error {1918var m bson.M1919if err := bson.Unmarshal(data, &m); err != nil {1920return err1921}1922
1923if ud, ok := m["data"].(string); ok {1924*r = RGBColor(ud)1925return nil1926}1927return errors.New("couldn't unmarshal bson bytes as RGBColor")1928}
1929
1930// DeepCopyInto copies the receiver and writes its value into out.
1931func (r *RGBColor) DeepCopyInto(out *RGBColor) {1932*out = *r1933}
1934
1935// DeepCopy copies the receiver into a new RGBColor.
1936func (r *RGBColor) DeepCopy() *RGBColor {1937if r == nil {1938return nil1939}1940out := new(RGBColor)1941r.DeepCopyInto(out)1942return out1943}
1944
1945// Password represents a password.
1946// This has no validations and is mainly used as a marker for UI components.
1947//
1948// swagger:strfmt password
1949type Password string1950
1951// MarshalText turns this instance into text
1952func (r Password) MarshalText() ([]byte, error) {1953return []byte(string(r)), nil1954}
1955
1956// UnmarshalText hydrates this instance from text
1957func (r *Password) UnmarshalText(data []byte) error { // validation is performed later on1958*r = Password(string(data))1959return nil1960}
1961
1962// Scan read a value from a database driver
1963func (r *Password) Scan(raw interface{}) error {1964switch v := raw.(type) {1965case []byte:1966*r = Password(string(v))1967case string:1968*r = Password(v)1969default:1970return fmt.Errorf("cannot sql.Scan() strfmt.Password from: %#v", v)1971}1972
1973return nil1974}
1975
1976// Value converts a value to a database driver value
1977func (r Password) Value() (driver.Value, error) {1978return driver.Value(string(r)), nil1979}
1980
1981func (r Password) String() string {1982return string(r)1983}
1984
1985// MarshalJSON returns the Password as JSON
1986func (r Password) MarshalJSON() ([]byte, error) {1987return json.Marshal(string(r))1988}
1989
1990// UnmarshalJSON sets the Password from JSON
1991func (r *Password) UnmarshalJSON(data []byte) error {1992if string(data) == jsonNull {1993return nil1994}1995var ustr string1996if err := json.Unmarshal(data, &ustr); err != nil {1997return err1998}1999*r = Password(ustr)2000return nil2001}
2002
2003// MarshalBSON document from this value
2004func (r Password) MarshalBSON() ([]byte, error) {2005return bson.Marshal(bson.M{"data": r.String()})2006}
2007
2008// UnmarshalBSON document into this value
2009func (r *Password) UnmarshalBSON(data []byte) error {2010var m bson.M2011if err := bson.Unmarshal(data, &m); err != nil {2012return err2013}2014
2015if ud, ok := m["data"].(string); ok {2016*r = Password(ud)2017return nil2018}2019return errors.New("couldn't unmarshal bson bytes as Password")2020}
2021
2022// DeepCopyInto copies the receiver and writes its value into out.
2023func (r *Password) DeepCopyInto(out *Password) {2024*out = *r2025}
2026
2027// DeepCopy copies the receiver into a new Password.
2028func (r *Password) DeepCopy() *Password {2029if r == nil {2030return nil2031}2032out := new(Password)2033r.DeepCopyInto(out)2034return out2035}
2036