1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package strfmt
16
17 import (
18 "encoding/base64"
19 "encoding/json"
20 "fmt"
21 "net/mail"
22 "regexp"
23 "strings"
24
25 "github.com/asaskevich/govalidator"
26
27 netutils "k8s.io/utils/net"
28 )
29
30 const (
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58 HostnamePattern = `^([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})$`
59
60 UUIDPattern = `(?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}$`
61
62 UUID3Pattern = `(?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?3[0-9a-f]{3}-?[0-9a-f]{4}-?[0-9a-f]{12}$`
63
64 UUID4Pattern = `(?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?4[0-9a-f]{3}-?[89ab][0-9a-f]{3}-?[0-9a-f]{12}$`
65
66 UUID5Pattern = `(?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?5[0-9a-f]{3}-?[89ab][0-9a-f]{3}-?[0-9a-f]{12}$`
67
68 jsonNull = "null"
69 )
70
71 var (
72 rxHostname = regexp.MustCompile(HostnamePattern)
73 rxUUID = regexp.MustCompile(UUIDPattern)
74 rxUUID3 = regexp.MustCompile(UUID3Pattern)
75 rxUUID4 = regexp.MustCompile(UUID4Pattern)
76 rxUUID5 = regexp.MustCompile(UUID5Pattern)
77 )
78
79
80 func IsHostname(str string) bool {
81 if !rxHostname.MatchString(str) {
82 return false
83 }
84
85
86 if len(str) > 255 {
87 return false
88 }
89
90
91 parts := strings.Split(str, ".")
92 valid := true
93 for _, p := range parts {
94 if len(p) > 63 {
95 valid = false
96 }
97 }
98 return valid
99 }
100
101
102 func IsUUID(str string) bool {
103 return rxUUID.MatchString(str)
104 }
105
106
107 func IsUUID3(str string) bool {
108 return rxUUID3.MatchString(str)
109 }
110
111
112 func IsUUID4(str string) bool {
113 return rxUUID4.MatchString(str)
114 }
115
116
117 func IsUUID5(str string) bool {
118 return rxUUID5.MatchString(str)
119 }
120
121
122 func IsEmail(str string) bool {
123 addr, e := mail.ParseAddress(str)
124 return e == nil && addr.Address != ""
125 }
126
127 func init() {
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149 u := URI("")
150 Default.Add("uri", &u, govalidator.IsRequestURI)
151
152 eml := Email("")
153 Default.Add("email", &eml, IsEmail)
154
155 hn := Hostname("")
156 Default.Add("hostname", &hn, IsHostname)
157
158 ip4 := IPv4("")
159 Default.Add("ipv4", &ip4, isIPv4)
160
161 ip6 := IPv6("")
162 Default.Add("ipv6", &ip6, govalidator.IsIPv6)
163
164 cidr := CIDR("")
165 Default.Add("cidr", &cidr, isCIDR)
166
167 mac := MAC("")
168 Default.Add("mac", &mac, govalidator.IsMAC)
169
170 uid := UUID("")
171 Default.Add("uuid", &uid, IsUUID)
172
173 uid3 := UUID3("")
174 Default.Add("uuid3", &uid3, IsUUID3)
175
176 uid4 := UUID4("")
177 Default.Add("uuid4", &uid4, IsUUID4)
178
179 uid5 := UUID5("")
180 Default.Add("uuid5", &uid5, IsUUID5)
181
182 isbn := ISBN("")
183 Default.Add("isbn", &isbn, func(str string) bool { return govalidator.IsISBN10(str) || govalidator.IsISBN13(str) })
184
185 isbn10 := ISBN10("")
186 Default.Add("isbn10", &isbn10, govalidator.IsISBN10)
187
188 isbn13 := ISBN13("")
189 Default.Add("isbn13", &isbn13, govalidator.IsISBN13)
190
191 cc := CreditCard("")
192 Default.Add("creditcard", &cc, govalidator.IsCreditCard)
193
194 ssn := SSN("")
195 Default.Add("ssn", &ssn, govalidator.IsSSN)
196
197 hc := HexColor("")
198 Default.Add("hexcolor", &hc, govalidator.IsHexcolor)
199
200 rc := RGBColor("")
201 Default.Add("rgbcolor", &rc, govalidator.IsRGBcolor)
202
203 b64 := Base64([]byte(nil))
204 Default.Add("byte", &b64, govalidator.IsBase64)
205
206 pw := Password("")
207 Default.Add("password", &pw, func(_ string) bool { return true })
208 }
209
210
211 func isIPv4(s string) bool {
212 ip := netutils.ParseIPSloppy(s)
213 return ip != nil && strings.Contains(s, ".")
214 }
215
216
217 func isCIDR(s string) bool {
218 _, _, err := netutils.ParseCIDRSloppy(s)
219 return err == nil
220 }
221
222
223
224
225 type Base64 []byte
226
227
228 func (b Base64) MarshalText() ([]byte, error) {
229 enc := base64.URLEncoding
230 src := []byte(b)
231 buf := make([]byte, enc.EncodedLen(len(src)))
232 enc.Encode(buf, src)
233 return buf, nil
234 }
235
236
237 func (b *Base64) UnmarshalText(data []byte) error {
238 enc := base64.URLEncoding
239 dbuf := make([]byte, enc.DecodedLen(len(data)))
240
241 n, err := enc.Decode(dbuf, data)
242 if err != nil {
243 return err
244 }
245
246 *b = dbuf[:n]
247 return nil
248 }
249
250
251 func (b *Base64) Scan(raw interface{}) error {
252 switch v := raw.(type) {
253 case []byte:
254 dbuf := make([]byte, base64.StdEncoding.DecodedLen(len(v)))
255 n, err := base64.StdEncoding.Decode(dbuf, v)
256 if err != nil {
257 return err
258 }
259 *b = dbuf[:n]
260 case string:
261 vv, err := base64.StdEncoding.DecodeString(v)
262 if err != nil {
263 return err
264 }
265 *b = Base64(vv)
266 default:
267 return fmt.Errorf("cannot sql.Scan() strfmt.Base64 from: %#v", v)
268 }
269
270 return nil
271 }
272
273 func (b Base64) String() string {
274 return base64.StdEncoding.EncodeToString([]byte(b))
275 }
276
277
278 func (b Base64) MarshalJSON() ([]byte, error) {
279 return json.Marshal(b.String())
280 }
281
282
283 func (b *Base64) UnmarshalJSON(data []byte) error {
284 var b64str string
285 if err := json.Unmarshal(data, &b64str); err != nil {
286 return err
287 }
288 vb, err := base64.StdEncoding.DecodeString(b64str)
289 if err != nil {
290 return err
291 }
292 *b = Base64(vb)
293 return nil
294 }
295
296
297 func (b *Base64) DeepCopyInto(out *Base64) {
298 *out = *b
299 }
300
301
302 func (b *Base64) DeepCopy() *Base64 {
303 if b == nil {
304 return nil
305 }
306 out := new(Base64)
307 b.DeepCopyInto(out)
308 return out
309 }
310
311
312
313
314 type URI string
315
316
317 func (u URI) MarshalText() ([]byte, error) {
318 return []byte(string(u)), nil
319 }
320
321
322 func (u *URI) UnmarshalText(data []byte) error {
323 *u = URI(string(data))
324 return nil
325 }
326
327
328 func (u *URI) Scan(raw interface{}) error {
329 switch v := raw.(type) {
330 case []byte:
331 *u = URI(string(v))
332 case string:
333 *u = URI(v)
334 default:
335 return fmt.Errorf("cannot sql.Scan() strfmt.URI from: %#v", v)
336 }
337
338 return nil
339 }
340
341 func (u URI) String() string {
342 return string(u)
343 }
344
345
346 func (u URI) MarshalJSON() ([]byte, error) {
347 return json.Marshal(string(u))
348 }
349
350
351 func (u *URI) UnmarshalJSON(data []byte) error {
352 var uristr string
353 if err := json.Unmarshal(data, &uristr); err != nil {
354 return err
355 }
356 *u = URI(uristr)
357 return nil
358 }
359
360
361 func (u *URI) DeepCopyInto(out *URI) {
362 *out = *u
363 }
364
365
366 func (u *URI) DeepCopy() *URI {
367 if u == nil {
368 return nil
369 }
370 out := new(URI)
371 u.DeepCopyInto(out)
372 return out
373 }
374
375
376
377
378 type Email string
379
380
381 func (e Email) MarshalText() ([]byte, error) {
382 return []byte(string(e)), nil
383 }
384
385
386 func (e *Email) UnmarshalText(data []byte) error {
387 *e = Email(string(data))
388 return nil
389 }
390
391
392 func (e *Email) Scan(raw interface{}) error {
393 switch v := raw.(type) {
394 case []byte:
395 *e = Email(string(v))
396 case string:
397 *e = Email(v)
398 default:
399 return fmt.Errorf("cannot sql.Scan() strfmt.Email from: %#v", v)
400 }
401
402 return nil
403 }
404
405 func (e Email) String() string {
406 return string(e)
407 }
408
409
410 func (e Email) MarshalJSON() ([]byte, error) {
411 return json.Marshal(string(e))
412 }
413
414
415 func (e *Email) UnmarshalJSON(data []byte) error {
416 var estr string
417 if err := json.Unmarshal(data, &estr); err != nil {
418 return err
419 }
420 *e = Email(estr)
421 return nil
422 }
423
424
425 func (e *Email) DeepCopyInto(out *Email) {
426 *out = *e
427 }
428
429
430 func (e *Email) DeepCopy() *Email {
431 if e == nil {
432 return nil
433 }
434 out := new(Email)
435 e.DeepCopyInto(out)
436 return out
437 }
438
439
440
441
442 type Hostname string
443
444
445 func (h Hostname) MarshalText() ([]byte, error) {
446 return []byte(string(h)), nil
447 }
448
449
450 func (h *Hostname) UnmarshalText(data []byte) error {
451 *h = Hostname(string(data))
452 return nil
453 }
454
455
456 func (h *Hostname) Scan(raw interface{}) error {
457 switch v := raw.(type) {
458 case []byte:
459 *h = Hostname(string(v))
460 case string:
461 *h = Hostname(v)
462 default:
463 return fmt.Errorf("cannot sql.Scan() strfmt.Hostname from: %#v", v)
464 }
465
466 return nil
467 }
468
469 func (h Hostname) String() string {
470 return string(h)
471 }
472
473
474 func (h Hostname) MarshalJSON() ([]byte, error) {
475 return json.Marshal(string(h))
476 }
477
478
479 func (h *Hostname) UnmarshalJSON(data []byte) error {
480 var hstr string
481 if err := json.Unmarshal(data, &hstr); err != nil {
482 return err
483 }
484 *h = Hostname(hstr)
485 return nil
486 }
487
488
489 func (h *Hostname) DeepCopyInto(out *Hostname) {
490 *out = *h
491 }
492
493
494 func (h *Hostname) DeepCopy() *Hostname {
495 if h == nil {
496 return nil
497 }
498 out := new(Hostname)
499 h.DeepCopyInto(out)
500 return out
501 }
502
503
504
505
506 type IPv4 string
507
508
509 func (u IPv4) MarshalText() ([]byte, error) {
510 return []byte(string(u)), nil
511 }
512
513
514 func (u *IPv4) UnmarshalText(data []byte) error {
515 *u = IPv4(string(data))
516 return nil
517 }
518
519
520 func (u *IPv4) Scan(raw interface{}) error {
521 switch v := raw.(type) {
522 case []byte:
523 *u = IPv4(string(v))
524 case string:
525 *u = IPv4(v)
526 default:
527 return fmt.Errorf("cannot sql.Scan() strfmt.IPv4 from: %#v", v)
528 }
529
530 return nil
531 }
532
533 func (u IPv4) String() string {
534 return string(u)
535 }
536
537
538 func (u IPv4) MarshalJSON() ([]byte, error) {
539 return json.Marshal(string(u))
540 }
541
542
543 func (u *IPv4) UnmarshalJSON(data []byte) error {
544 var ustr string
545 if err := json.Unmarshal(data, &ustr); err != nil {
546 return err
547 }
548 *u = IPv4(ustr)
549 return nil
550 }
551
552
553 func (u *IPv4) DeepCopyInto(out *IPv4) {
554 *out = *u
555 }
556
557
558 func (u *IPv4) DeepCopy() *IPv4 {
559 if u == nil {
560 return nil
561 }
562 out := new(IPv4)
563 u.DeepCopyInto(out)
564 return out
565 }
566
567
568
569
570 type IPv6 string
571
572
573 func (u IPv6) MarshalText() ([]byte, error) {
574 return []byte(string(u)), nil
575 }
576
577
578 func (u *IPv6) UnmarshalText(data []byte) error {
579 *u = IPv6(string(data))
580 return nil
581 }
582
583
584 func (u *IPv6) Scan(raw interface{}) error {
585 switch v := raw.(type) {
586 case []byte:
587 *u = IPv6(string(v))
588 case string:
589 *u = IPv6(v)
590 default:
591 return fmt.Errorf("cannot sql.Scan() strfmt.IPv6 from: %#v", v)
592 }
593
594 return nil
595 }
596
597 func (u IPv6) String() string {
598 return string(u)
599 }
600
601
602 func (u IPv6) MarshalJSON() ([]byte, error) {
603 return json.Marshal(string(u))
604 }
605
606
607 func (u *IPv6) UnmarshalJSON(data []byte) error {
608 var ustr string
609 if err := json.Unmarshal(data, &ustr); err != nil {
610 return err
611 }
612 *u = IPv6(ustr)
613 return nil
614 }
615
616
617 func (u *IPv6) DeepCopyInto(out *IPv6) {
618 *out = *u
619 }
620
621
622 func (u *IPv6) DeepCopy() *IPv6 {
623 if u == nil {
624 return nil
625 }
626 out := new(IPv6)
627 u.DeepCopyInto(out)
628 return out
629 }
630
631
632
633
634 type CIDR string
635
636
637 func (u CIDR) MarshalText() ([]byte, error) {
638 return []byte(string(u)), nil
639 }
640
641
642 func (u *CIDR) UnmarshalText(data []byte) error {
643 *u = CIDR(string(data))
644 return nil
645 }
646
647
648 func (u *CIDR) Scan(raw interface{}) error {
649 switch v := raw.(type) {
650 case []byte:
651 *u = CIDR(string(v))
652 case string:
653 *u = CIDR(v)
654 default:
655 return fmt.Errorf("cannot sql.Scan() strfmt.CIDR from: %#v", v)
656 }
657
658 return nil
659 }
660
661 func (u CIDR) String() string {
662 return string(u)
663 }
664
665
666 func (u CIDR) MarshalJSON() ([]byte, error) {
667 return json.Marshal(string(u))
668 }
669
670
671 func (u *CIDR) UnmarshalJSON(data []byte) error {
672 var ustr string
673 if err := json.Unmarshal(data, &ustr); err != nil {
674 return err
675 }
676 *u = CIDR(ustr)
677 return nil
678 }
679
680
681 func (u *CIDR) DeepCopyInto(out *CIDR) {
682 *out = *u
683 }
684
685
686 func (u *CIDR) DeepCopy() *CIDR {
687 if u == nil {
688 return nil
689 }
690 out := new(CIDR)
691 u.DeepCopyInto(out)
692 return out
693 }
694
695
696
697
698 type MAC string
699
700
701 func (u MAC) MarshalText() ([]byte, error) {
702 return []byte(string(u)), nil
703 }
704
705
706 func (u *MAC) UnmarshalText(data []byte) error {
707 *u = MAC(string(data))
708 return nil
709 }
710
711
712 func (u *MAC) Scan(raw interface{}) error {
713 switch v := raw.(type) {
714 case []byte:
715 *u = MAC(string(v))
716 case string:
717 *u = MAC(v)
718 default:
719 return fmt.Errorf("cannot sql.Scan() strfmt.IPv4 from: %#v", v)
720 }
721
722 return nil
723 }
724
725 func (u MAC) String() string {
726 return string(u)
727 }
728
729
730 func (u MAC) MarshalJSON() ([]byte, error) {
731 return json.Marshal(string(u))
732 }
733
734
735 func (u *MAC) UnmarshalJSON(data []byte) error {
736 var ustr string
737 if err := json.Unmarshal(data, &ustr); err != nil {
738 return err
739 }
740 *u = MAC(ustr)
741 return nil
742 }
743
744
745 func (u *MAC) DeepCopyInto(out *MAC) {
746 *out = *u
747 }
748
749
750 func (u *MAC) DeepCopy() *MAC {
751 if u == nil {
752 return nil
753 }
754 out := new(MAC)
755 u.DeepCopyInto(out)
756 return out
757 }
758
759
760
761
762 type UUID string
763
764
765 func (u UUID) MarshalText() ([]byte, error) {
766 return []byte(string(u)), nil
767 }
768
769
770 func (u *UUID) UnmarshalText(data []byte) error {
771 *u = UUID(string(data))
772 return nil
773 }
774
775
776 func (u *UUID) Scan(raw interface{}) error {
777 switch v := raw.(type) {
778 case []byte:
779 *u = UUID(string(v))
780 case string:
781 *u = UUID(v)
782 default:
783 return fmt.Errorf("cannot sql.Scan() strfmt.UUID from: %#v", v)
784 }
785
786 return nil
787 }
788
789 func (u UUID) String() string {
790 return string(u)
791 }
792
793
794 func (u UUID) MarshalJSON() ([]byte, error) {
795 return json.Marshal(string(u))
796 }
797
798
799 func (u *UUID) UnmarshalJSON(data []byte) error {
800 if string(data) == jsonNull {
801 return nil
802 }
803 var ustr string
804 if err := json.Unmarshal(data, &ustr); err != nil {
805 return err
806 }
807 *u = UUID(ustr)
808 return nil
809 }
810
811
812 func (u *UUID) DeepCopyInto(out *UUID) {
813 *out = *u
814 }
815
816
817 func (u *UUID) DeepCopy() *UUID {
818 if u == nil {
819 return nil
820 }
821 out := new(UUID)
822 u.DeepCopyInto(out)
823 return out
824 }
825
826
827
828
829 type UUID3 string
830
831
832 func (u UUID3) MarshalText() ([]byte, error) {
833 return []byte(string(u)), nil
834 }
835
836
837 func (u *UUID3) UnmarshalText(data []byte) error {
838 *u = UUID3(string(data))
839 return nil
840 }
841
842
843 func (u *UUID3) Scan(raw interface{}) error {
844 switch v := raw.(type) {
845 case []byte:
846 *u = UUID3(string(v))
847 case string:
848 *u = UUID3(v)
849 default:
850 return fmt.Errorf("cannot sql.Scan() strfmt.UUID3 from: %#v", v)
851 }
852
853 return nil
854 }
855
856 func (u UUID3) String() string {
857 return string(u)
858 }
859
860
861 func (u UUID3) MarshalJSON() ([]byte, error) {
862 return json.Marshal(string(u))
863 }
864
865
866 func (u *UUID3) UnmarshalJSON(data []byte) error {
867 if string(data) == jsonNull {
868 return nil
869 }
870 var ustr string
871 if err := json.Unmarshal(data, &ustr); err != nil {
872 return err
873 }
874 *u = UUID3(ustr)
875 return nil
876 }
877
878
879 func (u *UUID3) DeepCopyInto(out *UUID3) {
880 *out = *u
881 }
882
883
884 func (u *UUID3) DeepCopy() *UUID3 {
885 if u == nil {
886 return nil
887 }
888 out := new(UUID3)
889 u.DeepCopyInto(out)
890 return out
891 }
892
893
894
895
896 type UUID4 string
897
898
899 func (u UUID4) MarshalText() ([]byte, error) {
900 return []byte(string(u)), nil
901 }
902
903
904 func (u *UUID4) UnmarshalText(data []byte) error {
905 *u = UUID4(string(data))
906 return nil
907 }
908
909
910 func (u *UUID4) Scan(raw interface{}) error {
911 switch v := raw.(type) {
912 case []byte:
913 *u = UUID4(string(v))
914 case string:
915 *u = UUID4(v)
916 default:
917 return fmt.Errorf("cannot sql.Scan() strfmt.UUID4 from: %#v", v)
918 }
919
920 return nil
921 }
922
923 func (u UUID4) String() string {
924 return string(u)
925 }
926
927
928 func (u UUID4) MarshalJSON() ([]byte, error) {
929 return json.Marshal(string(u))
930 }
931
932
933 func (u *UUID4) UnmarshalJSON(data []byte) error {
934 if string(data) == jsonNull {
935 return nil
936 }
937 var ustr string
938 if err := json.Unmarshal(data, &ustr); err != nil {
939 return err
940 }
941 *u = UUID4(ustr)
942 return nil
943 }
944
945
946 func (u *UUID4) DeepCopyInto(out *UUID4) {
947 *out = *u
948 }
949
950
951 func (u *UUID4) DeepCopy() *UUID4 {
952 if u == nil {
953 return nil
954 }
955 out := new(UUID4)
956 u.DeepCopyInto(out)
957 return out
958 }
959
960
961
962
963 type UUID5 string
964
965
966 func (u UUID5) MarshalText() ([]byte, error) {
967 return []byte(string(u)), nil
968 }
969
970
971 func (u *UUID5) UnmarshalText(data []byte) error {
972 *u = UUID5(string(data))
973 return nil
974 }
975
976
977 func (u *UUID5) Scan(raw interface{}) error {
978 switch v := raw.(type) {
979 case []byte:
980 *u = UUID5(string(v))
981 case string:
982 *u = UUID5(v)
983 default:
984 return fmt.Errorf("cannot sql.Scan() strfmt.UUID5 from: %#v", v)
985 }
986
987 return nil
988 }
989
990 func (u UUID5) String() string {
991 return string(u)
992 }
993
994
995 func (u UUID5) MarshalJSON() ([]byte, error) {
996 return json.Marshal(string(u))
997 }
998
999
1000 func (u *UUID5) UnmarshalJSON(data []byte) error {
1001 if string(data) == jsonNull {
1002 return nil
1003 }
1004 var ustr string
1005 if err := json.Unmarshal(data, &ustr); err != nil {
1006 return err
1007 }
1008 *u = UUID5(ustr)
1009 return nil
1010 }
1011
1012
1013 func (u *UUID5) DeepCopyInto(out *UUID5) {
1014 *out = *u
1015 }
1016
1017
1018 func (u *UUID5) DeepCopy() *UUID5 {
1019 if u == nil {
1020 return nil
1021 }
1022 out := new(UUID5)
1023 u.DeepCopyInto(out)
1024 return out
1025 }
1026
1027
1028
1029
1030 type ISBN string
1031
1032
1033 func (u ISBN) MarshalText() ([]byte, error) {
1034 return []byte(string(u)), nil
1035 }
1036
1037
1038 func (u *ISBN) UnmarshalText(data []byte) error {
1039 *u = ISBN(string(data))
1040 return nil
1041 }
1042
1043
1044 func (u *ISBN) Scan(raw interface{}) error {
1045 switch v := raw.(type) {
1046 case []byte:
1047 *u = ISBN(string(v))
1048 case string:
1049 *u = ISBN(v)
1050 default:
1051 return fmt.Errorf("cannot sql.Scan() strfmt.ISBN from: %#v", v)
1052 }
1053
1054 return nil
1055 }
1056
1057 func (u ISBN) String() string {
1058 return string(u)
1059 }
1060
1061
1062 func (u ISBN) MarshalJSON() ([]byte, error) {
1063 return json.Marshal(string(u))
1064 }
1065
1066
1067 func (u *ISBN) UnmarshalJSON(data []byte) error {
1068 if string(data) == jsonNull {
1069 return nil
1070 }
1071 var ustr string
1072 if err := json.Unmarshal(data, &ustr); err != nil {
1073 return err
1074 }
1075 *u = ISBN(ustr)
1076 return nil
1077 }
1078
1079
1080 func (u *ISBN) DeepCopyInto(out *ISBN) {
1081 *out = *u
1082 }
1083
1084
1085 func (u *ISBN) DeepCopy() *ISBN {
1086 if u == nil {
1087 return nil
1088 }
1089 out := new(ISBN)
1090 u.DeepCopyInto(out)
1091 return out
1092 }
1093
1094
1095
1096
1097 type ISBN10 string
1098
1099
1100 func (u ISBN10) MarshalText() ([]byte, error) {
1101 return []byte(string(u)), nil
1102 }
1103
1104
1105 func (u *ISBN10) UnmarshalText(data []byte) error {
1106 *u = ISBN10(string(data))
1107 return nil
1108 }
1109
1110
1111 func (u *ISBN10) Scan(raw interface{}) error {
1112 switch v := raw.(type) {
1113 case []byte:
1114 *u = ISBN10(string(v))
1115 case string:
1116 *u = ISBN10(v)
1117 default:
1118 return fmt.Errorf("cannot sql.Scan() strfmt.ISBN10 from: %#v", v)
1119 }
1120
1121 return nil
1122 }
1123
1124 func (u ISBN10) String() string {
1125 return string(u)
1126 }
1127
1128
1129 func (u ISBN10) MarshalJSON() ([]byte, error) {
1130 return json.Marshal(string(u))
1131 }
1132
1133
1134 func (u *ISBN10) UnmarshalJSON(data []byte) error {
1135 if string(data) == jsonNull {
1136 return nil
1137 }
1138 var ustr string
1139 if err := json.Unmarshal(data, &ustr); err != nil {
1140 return err
1141 }
1142 *u = ISBN10(ustr)
1143 return nil
1144 }
1145
1146
1147 func (u *ISBN10) DeepCopyInto(out *ISBN10) {
1148 *out = *u
1149 }
1150
1151
1152 func (u *ISBN10) DeepCopy() *ISBN10 {
1153 if u == nil {
1154 return nil
1155 }
1156 out := new(ISBN10)
1157 u.DeepCopyInto(out)
1158 return out
1159 }
1160
1161
1162
1163
1164 type ISBN13 string
1165
1166
1167 func (u ISBN13) MarshalText() ([]byte, error) {
1168 return []byte(string(u)), nil
1169 }
1170
1171
1172 func (u *ISBN13) UnmarshalText(data []byte) error {
1173 *u = ISBN13(string(data))
1174 return nil
1175 }
1176
1177
1178 func (u *ISBN13) Scan(raw interface{}) error {
1179 switch v := raw.(type) {
1180 case []byte:
1181 *u = ISBN13(string(v))
1182 case string:
1183 *u = ISBN13(v)
1184 default:
1185 return fmt.Errorf("cannot sql.Scan() strfmt.ISBN13 from: %#v", v)
1186 }
1187
1188 return nil
1189 }
1190
1191 func (u ISBN13) String() string {
1192 return string(u)
1193 }
1194
1195
1196 func (u ISBN13) MarshalJSON() ([]byte, error) {
1197 return json.Marshal(string(u))
1198 }
1199
1200
1201 func (u *ISBN13) UnmarshalJSON(data []byte) error {
1202 if string(data) == jsonNull {
1203 return nil
1204 }
1205 var ustr string
1206 if err := json.Unmarshal(data, &ustr); err != nil {
1207 return err
1208 }
1209 *u = ISBN13(ustr)
1210 return nil
1211 }
1212
1213
1214 func (u *ISBN13) DeepCopyInto(out *ISBN13) {
1215 *out = *u
1216 }
1217
1218
1219 func (u *ISBN13) DeepCopy() *ISBN13 {
1220 if u == nil {
1221 return nil
1222 }
1223 out := new(ISBN13)
1224 u.DeepCopyInto(out)
1225 return out
1226 }
1227
1228
1229
1230
1231 type CreditCard string
1232
1233
1234 func (u CreditCard) MarshalText() ([]byte, error) {
1235 return []byte(string(u)), nil
1236 }
1237
1238
1239 func (u *CreditCard) UnmarshalText(data []byte) error {
1240 *u = CreditCard(string(data))
1241 return nil
1242 }
1243
1244
1245 func (u *CreditCard) Scan(raw interface{}) error {
1246 switch v := raw.(type) {
1247 case []byte:
1248 *u = CreditCard(string(v))
1249 case string:
1250 *u = CreditCard(v)
1251 default:
1252 return fmt.Errorf("cannot sql.Scan() strfmt.CreditCard from: %#v", v)
1253 }
1254
1255 return nil
1256 }
1257
1258 func (u CreditCard) String() string {
1259 return string(u)
1260 }
1261
1262
1263 func (u CreditCard) MarshalJSON() ([]byte, error) {
1264 return json.Marshal(string(u))
1265 }
1266
1267
1268 func (u *CreditCard) UnmarshalJSON(data []byte) error {
1269 if string(data) == jsonNull {
1270 return nil
1271 }
1272 var ustr string
1273 if err := json.Unmarshal(data, &ustr); err != nil {
1274 return err
1275 }
1276 *u = CreditCard(ustr)
1277 return nil
1278 }
1279
1280
1281 func (u *CreditCard) DeepCopyInto(out *CreditCard) {
1282 *out = *u
1283 }
1284
1285
1286 func (u *CreditCard) DeepCopy() *CreditCard {
1287 if u == nil {
1288 return nil
1289 }
1290 out := new(CreditCard)
1291 u.DeepCopyInto(out)
1292 return out
1293 }
1294
1295
1296
1297
1298 type SSN string
1299
1300
1301 func (u SSN) MarshalText() ([]byte, error) {
1302 return []byte(string(u)), nil
1303 }
1304
1305
1306 func (u *SSN) UnmarshalText(data []byte) error {
1307 *u = SSN(string(data))
1308 return nil
1309 }
1310
1311
1312 func (u *SSN) Scan(raw interface{}) error {
1313 switch v := raw.(type) {
1314 case []byte:
1315 *u = SSN(string(v))
1316 case string:
1317 *u = SSN(v)
1318 default:
1319 return fmt.Errorf("cannot sql.Scan() strfmt.SSN from: %#v", v)
1320 }
1321
1322 return nil
1323 }
1324
1325 func (u SSN) String() string {
1326 return string(u)
1327 }
1328
1329
1330 func (u SSN) MarshalJSON() ([]byte, error) {
1331 return json.Marshal(string(u))
1332 }
1333
1334
1335 func (u *SSN) UnmarshalJSON(data []byte) error {
1336 if string(data) == jsonNull {
1337 return nil
1338 }
1339 var ustr string
1340 if err := json.Unmarshal(data, &ustr); err != nil {
1341 return err
1342 }
1343 *u = SSN(ustr)
1344 return nil
1345 }
1346
1347
1348 func (u *SSN) DeepCopyInto(out *SSN) {
1349 *out = *u
1350 }
1351
1352
1353 func (u *SSN) DeepCopy() *SSN {
1354 if u == nil {
1355 return nil
1356 }
1357 out := new(SSN)
1358 u.DeepCopyInto(out)
1359 return out
1360 }
1361
1362
1363
1364
1365 type HexColor string
1366
1367
1368 func (h HexColor) MarshalText() ([]byte, error) {
1369 return []byte(string(h)), nil
1370 }
1371
1372
1373 func (h *HexColor) UnmarshalText(data []byte) error {
1374 *h = HexColor(string(data))
1375 return nil
1376 }
1377
1378
1379 func (h *HexColor) Scan(raw interface{}) error {
1380 switch v := raw.(type) {
1381 case []byte:
1382 *h = HexColor(string(v))
1383 case string:
1384 *h = HexColor(v)
1385 default:
1386 return fmt.Errorf("cannot sql.Scan() strfmt.HexColor from: %#v", v)
1387 }
1388
1389 return nil
1390 }
1391
1392 func (h HexColor) String() string {
1393 return string(h)
1394 }
1395
1396
1397 func (h HexColor) MarshalJSON() ([]byte, error) {
1398 return json.Marshal(string(h))
1399 }
1400
1401
1402 func (h *HexColor) UnmarshalJSON(data []byte) error {
1403 if string(data) == jsonNull {
1404 return nil
1405 }
1406 var ustr string
1407 if err := json.Unmarshal(data, &ustr); err != nil {
1408 return err
1409 }
1410 *h = HexColor(ustr)
1411 return nil
1412 }
1413
1414
1415 func (h *HexColor) DeepCopyInto(out *HexColor) {
1416 *out = *h
1417 }
1418
1419
1420 func (h *HexColor) DeepCopy() *HexColor {
1421 if h == nil {
1422 return nil
1423 }
1424 out := new(HexColor)
1425 h.DeepCopyInto(out)
1426 return out
1427 }
1428
1429
1430
1431
1432 type RGBColor string
1433
1434
1435 func (r RGBColor) MarshalText() ([]byte, error) {
1436 return []byte(string(r)), nil
1437 }
1438
1439
1440 func (r *RGBColor) UnmarshalText(data []byte) error {
1441 *r = RGBColor(string(data))
1442 return nil
1443 }
1444
1445
1446 func (r *RGBColor) Scan(raw interface{}) error {
1447 switch v := raw.(type) {
1448 case []byte:
1449 *r = RGBColor(string(v))
1450 case string:
1451 *r = RGBColor(v)
1452 default:
1453 return fmt.Errorf("cannot sql.Scan() strfmt.RGBColor from: %#v", v)
1454 }
1455
1456 return nil
1457 }
1458
1459 func (r RGBColor) String() string {
1460 return string(r)
1461 }
1462
1463
1464 func (r RGBColor) MarshalJSON() ([]byte, error) {
1465 return json.Marshal(string(r))
1466 }
1467
1468
1469 func (r *RGBColor) UnmarshalJSON(data []byte) error {
1470 if string(data) == jsonNull {
1471 return nil
1472 }
1473 var ustr string
1474 if err := json.Unmarshal(data, &ustr); err != nil {
1475 return err
1476 }
1477 *r = RGBColor(ustr)
1478 return nil
1479 }
1480
1481
1482 func (r *RGBColor) DeepCopyInto(out *RGBColor) {
1483 *out = *r
1484 }
1485
1486
1487 func (r *RGBColor) DeepCopy() *RGBColor {
1488 if r == nil {
1489 return nil
1490 }
1491 out := new(RGBColor)
1492 r.DeepCopyInto(out)
1493 return out
1494 }
1495
1496
1497
1498
1499
1500 type Password string
1501
1502
1503 func (r Password) MarshalText() ([]byte, error) {
1504 return []byte(string(r)), nil
1505 }
1506
1507
1508 func (r *Password) UnmarshalText(data []byte) error {
1509 *r = Password(string(data))
1510 return nil
1511 }
1512
1513
1514 func (r *Password) Scan(raw interface{}) error {
1515 switch v := raw.(type) {
1516 case []byte:
1517 *r = Password(string(v))
1518 case string:
1519 *r = Password(v)
1520 default:
1521 return fmt.Errorf("cannot sql.Scan() strfmt.Password from: %#v", v)
1522 }
1523
1524 return nil
1525 }
1526
1527 func (r Password) String() string {
1528 return string(r)
1529 }
1530
1531
1532 func (r Password) MarshalJSON() ([]byte, error) {
1533 return json.Marshal(string(r))
1534 }
1535
1536
1537 func (r *Password) UnmarshalJSON(data []byte) error {
1538 if string(data) == jsonNull {
1539 return nil
1540 }
1541 var ustr string
1542 if err := json.Unmarshal(data, &ustr); err != nil {
1543 return err
1544 }
1545 *r = Password(ustr)
1546 return nil
1547 }
1548
1549
1550 func (r *Password) DeepCopyInto(out *Password) {
1551 *out = *r
1552 }
1553
1554
1555 func (r *Password) DeepCopy() *Password {
1556 if r == nil {
1557 return nil
1558 }
1559 out := new(Password)
1560 r.DeepCopyInto(out)
1561 return out
1562 }
1563
View as plain text