k8s.io/kube-openapi@v0.0.0-20240228011516-70dd3763d340/pkg/validation/strfmt/default.go (about)

     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  
    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  	// HostnamePattern http://json-schema.org/latest/json-schema-validation.html#anchor114
    32  	//  A string instance is valid against this attribute if it is a valid
    33  	//  representation for an Internet host name, as defined by RFC 1034, section 3.1 [RFC1034].
    34  	//  http://tools.ietf.org/html/rfc1034#section-3.5
    35  	//  <digit> ::= any one of the ten digits 0 through 9
    36  	//  var digit = /[0-9]/;
    37  	//  <letter> ::= any one of the 52 alphabetic characters A through Z in upper case and a through z in lower case
    38  	//  var letter = /[a-zA-Z]/;
    39  	//  <let-dig> ::= <letter> | <digit>
    40  	//  var letDig = /[0-9a-zA-Z]/;
    41  	//  <let-dig-hyp> ::= <let-dig> | "-"
    42  	//  var letDigHyp = /[-0-9a-zA-Z]/;
    43  	//  <ldh-str> ::= <let-dig-hyp> | <let-dig-hyp> <ldh-str>
    44  	//  var ldhStr = /[-0-9a-zA-Z]+/;
    45  	//  <label> ::= <letter> [ [ <ldh-str> ] <let-dig> ]
    46  	//  var label = /[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?/;
    47  	//  <subdomain> ::= <label> | <subdomain> "." <label>
    48  	//  var subdomain = /^[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?(\.[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?)*$/;
    49  	//  <domain> ::= <subdomain> | " "
    50  	//
    51  	// Additional validations:
    52  	//   - for FDQNs, top-level domain (e.g. ".com"), is at least to letters long (no special characters here)
    53  	//   - hostnames may start with a digit [RFC1123]
    54  	//   - special registered names with an underscore ('_') are not allowed in this context
    55  	//   - dashes are permitted, but not at the start or the end of a segment
    56  	//   - long top-level domain names (e.g. example.london) are permitted
    57  	//   - symbol unicode points are permitted (e.g. emoji) (not for top-level domain)
    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  	// UUIDPattern Regex for UUID that allows uppercase
    60  	UUIDPattern = `(?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}$`
    61  	// UUID3Pattern Regex for UUID3 that allows uppercase
    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  	// UUID4Pattern Regex for UUID4 that allows uppercase
    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  	// UUID5Pattern Regex for UUID5 that allows uppercase
    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  	// json null type
    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  // IsHostname returns true when the string is a valid hostname
    80  func IsHostname(str string) bool {
    81  	if !rxHostname.MatchString(str) {
    82  		return false
    83  	}
    84  
    85  	// the sum of all label octets and label lengths is limited to 255.
    86  	if len(str) > 255 {
    87  		return false
    88  	}
    89  
    90  	// Each node has a label, which is zero to 63 octets in length
    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  // IsUUID returns true is the string matches a UUID, upper case is allowed
   102  func IsUUID(str string) bool {
   103  	return rxUUID.MatchString(str)
   104  }
   105  
   106  // IsUUID3 returns true is the string matches a UUID, upper case is allowed
   107  func IsUUID3(str string) bool {
   108  	return rxUUID3.MatchString(str)
   109  }
   110  
   111  // IsUUID4 returns true is the string matches a UUID, upper case is allowed
   112  func IsUUID4(str string) bool {
   113  	return rxUUID4.MatchString(str)
   114  }
   115  
   116  // IsUUID5 returns true is the string matches a UUID, upper case is allowed
   117  func IsUUID5(str string) bool {
   118  	return rxUUID5.MatchString(str)
   119  }
   120  
   121  // IsEmail validates an email address.
   122  func IsEmail(str string) bool {
   123  	addr, e := mail.ParseAddress(str)
   124  	return e == nil && addr.Address != ""
   125  }
   126  
   127  func init() {
   128  	// register formats in the default registry:
   129  	//   - byte
   130  	//   - creditcard
   131  	//   - email
   132  	//   - hexcolor
   133  	//   - hostname
   134  	//   - ipv4
   135  	//   - ipv6
   136  	//   - cidr
   137  	//   - isbn
   138  	//   - isbn10
   139  	//   - isbn13
   140  	//   - mac
   141  	//   - password
   142  	//   - rgbcolor
   143  	//   - ssn
   144  	//   - uri
   145  	//   - uuid
   146  	//   - uuid3
   147  	//   - uuid4
   148  	//   - uuid5
   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  // isIPv4 checks if the string is an IPv4 address, tolerating leading 0's for compatibility with go < 1.17.
   211  func isIPv4(s string) bool {
   212  	ip := netutils.ParseIPSloppy(s)
   213  	return ip != nil && strings.Contains(s, ".")
   214  }
   215  
   216  // isCIDR checks if the string is valid CIDR notation, tolerating leading 0's for compatibility with go < 1.17.
   217  func isCIDR(s string) bool {
   218  	_, _, err := netutils.ParseCIDRSloppy(s)
   219  	return err == nil
   220  }
   221  
   222  // Base64 represents a base64 encoded string, using URLEncoding alphabet
   223  //
   224  // swagger:strfmt byte
   225  type Base64 []byte
   226  
   227  // MarshalText turns this instance into text
   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  // UnmarshalText hydrates this instance from text
   237  func (b *Base64) UnmarshalText(data []byte) error { // validation is performed later on
   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  // Scan read a value from a database driver
   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  // MarshalJSON returns the Base64 as JSON
   278  func (b Base64) MarshalJSON() ([]byte, error) {
   279  	return json.Marshal(b.String())
   280  }
   281  
   282  // UnmarshalJSON sets the Base64 from JSON
   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  // DeepCopyInto copies the receiver and writes its value into out.
   297  func (b *Base64) DeepCopyInto(out *Base64) {
   298  	*out = *b
   299  }
   300  
   301  // DeepCopy copies the receiver into a new Base64.
   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  // URI represents the uri string format as specified by the json schema spec
   312  //
   313  // swagger:strfmt uri
   314  type URI string
   315  
   316  // MarshalText turns this instance into text
   317  func (u URI) MarshalText() ([]byte, error) {
   318  	return []byte(string(u)), nil
   319  }
   320  
   321  // UnmarshalText hydrates this instance from text
   322  func (u *URI) UnmarshalText(data []byte) error { // validation is performed later on
   323  	*u = URI(string(data))
   324  	return nil
   325  }
   326  
   327  // Scan read a value from a database driver
   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  // MarshalJSON returns the URI as JSON
   346  func (u URI) MarshalJSON() ([]byte, error) {
   347  	return json.Marshal(string(u))
   348  }
   349  
   350  // UnmarshalJSON sets the URI from JSON
   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  // DeepCopyInto copies the receiver and writes its value into out.
   361  func (u *URI) DeepCopyInto(out *URI) {
   362  	*out = *u
   363  }
   364  
   365  // DeepCopy copies the receiver into a new URI.
   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  // Email represents the email string format as specified by the json schema spec
   376  //
   377  // swagger:strfmt email
   378  type Email string
   379  
   380  // MarshalText turns this instance into text
   381  func (e Email) MarshalText() ([]byte, error) {
   382  	return []byte(string(e)), nil
   383  }
   384  
   385  // UnmarshalText hydrates this instance from text
   386  func (e *Email) UnmarshalText(data []byte) error { // validation is performed later on
   387  	*e = Email(string(data))
   388  	return nil
   389  }
   390  
   391  // Scan read a value from a database driver
   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  // MarshalJSON returns the Email as JSON
   410  func (e Email) MarshalJSON() ([]byte, error) {
   411  	return json.Marshal(string(e))
   412  }
   413  
   414  // UnmarshalJSON sets the Email from JSON
   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  // DeepCopyInto copies the receiver and writes its value into out.
   425  func (e *Email) DeepCopyInto(out *Email) {
   426  	*out = *e
   427  }
   428  
   429  // DeepCopy copies the receiver into a new Email.
   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  // Hostname represents the hostname string format as specified by the json schema spec
   440  //
   441  // swagger:strfmt hostname
   442  type Hostname string
   443  
   444  // MarshalText turns this instance into text
   445  func (h Hostname) MarshalText() ([]byte, error) {
   446  	return []byte(string(h)), nil
   447  }
   448  
   449  // UnmarshalText hydrates this instance from text
   450  func (h *Hostname) UnmarshalText(data []byte) error { // validation is performed later on
   451  	*h = Hostname(string(data))
   452  	return nil
   453  }
   454  
   455  // Scan read a value from a database driver
   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  // MarshalJSON returns the Hostname as JSON
   474  func (h Hostname) MarshalJSON() ([]byte, error) {
   475  	return json.Marshal(string(h))
   476  }
   477  
   478  // UnmarshalJSON sets the Hostname from JSON
   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  // DeepCopyInto copies the receiver and writes its value into out.
   489  func (h *Hostname) DeepCopyInto(out *Hostname) {
   490  	*out = *h
   491  }
   492  
   493  // DeepCopy copies the receiver into a new Hostname.
   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  // IPv4 represents an IP v4 address
   504  //
   505  // swagger:strfmt ipv4
   506  type IPv4 string
   507  
   508  // MarshalText turns this instance into text
   509  func (u IPv4) MarshalText() ([]byte, error) {
   510  	return []byte(string(u)), nil
   511  }
   512  
   513  // UnmarshalText hydrates this instance from text
   514  func (u *IPv4) UnmarshalText(data []byte) error { // validation is performed later on
   515  	*u = IPv4(string(data))
   516  	return nil
   517  }
   518  
   519  // Scan read a value from a database driver
   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  // MarshalJSON returns the IPv4 as JSON
   538  func (u IPv4) MarshalJSON() ([]byte, error) {
   539  	return json.Marshal(string(u))
   540  }
   541  
   542  // UnmarshalJSON sets the IPv4 from JSON
   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  // DeepCopyInto copies the receiver and writes its value into out.
   553  func (u *IPv4) DeepCopyInto(out *IPv4) {
   554  	*out = *u
   555  }
   556  
   557  // DeepCopy copies the receiver into a new IPv4.
   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  // IPv6 represents an IP v6 address
   568  //
   569  // swagger:strfmt ipv6
   570  type IPv6 string
   571  
   572  // MarshalText turns this instance into text
   573  func (u IPv6) MarshalText() ([]byte, error) {
   574  	return []byte(string(u)), nil
   575  }
   576  
   577  // UnmarshalText hydrates this instance from text
   578  func (u *IPv6) UnmarshalText(data []byte) error { // validation is performed later on
   579  	*u = IPv6(string(data))
   580  	return nil
   581  }
   582  
   583  // Scan read a value from a database driver
   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  // MarshalJSON returns the IPv6 as JSON
   602  func (u IPv6) MarshalJSON() ([]byte, error) {
   603  	return json.Marshal(string(u))
   604  }
   605  
   606  // UnmarshalJSON sets the IPv6 from JSON
   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  // DeepCopyInto copies the receiver and writes its value into out.
   617  func (u *IPv6) DeepCopyInto(out *IPv6) {
   618  	*out = *u
   619  }
   620  
   621  // DeepCopy copies the receiver into a new IPv6.
   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  // CIDR represents a Classless Inter-Domain Routing notation
   632  //
   633  // swagger:strfmt cidr
   634  type CIDR string
   635  
   636  // MarshalText turns this instance into text
   637  func (u CIDR) MarshalText() ([]byte, error) {
   638  	return []byte(string(u)), nil
   639  }
   640  
   641  // UnmarshalText hydrates this instance from text
   642  func (u *CIDR) UnmarshalText(data []byte) error { // validation is performed later on
   643  	*u = CIDR(string(data))
   644  	return nil
   645  }
   646  
   647  // Scan read a value from a database driver
   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  // MarshalJSON returns the CIDR as JSON
   666  func (u CIDR) MarshalJSON() ([]byte, error) {
   667  	return json.Marshal(string(u))
   668  }
   669  
   670  // UnmarshalJSON sets the CIDR from JSON
   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  // DeepCopyInto copies the receiver and writes its value into out.
   681  func (u *CIDR) DeepCopyInto(out *CIDR) {
   682  	*out = *u
   683  }
   684  
   685  // DeepCopy copies the receiver into a new CIDR.
   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  // MAC represents a 48 bit MAC address
   696  //
   697  // swagger:strfmt mac
   698  type MAC string
   699  
   700  // MarshalText turns this instance into text
   701  func (u MAC) MarshalText() ([]byte, error) {
   702  	return []byte(string(u)), nil
   703  }
   704  
   705  // UnmarshalText hydrates this instance from text
   706  func (u *MAC) UnmarshalText(data []byte) error { // validation is performed later on
   707  	*u = MAC(string(data))
   708  	return nil
   709  }
   710  
   711  // Scan read a value from a database driver
   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  // MarshalJSON returns the MAC as JSON
   730  func (u MAC) MarshalJSON() ([]byte, error) {
   731  	return json.Marshal(string(u))
   732  }
   733  
   734  // UnmarshalJSON sets the MAC from JSON
   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  // DeepCopyInto copies the receiver and writes its value into out.
   745  func (u *MAC) DeepCopyInto(out *MAC) {
   746  	*out = *u
   747  }
   748  
   749  // DeepCopy copies the receiver into a new MAC.
   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  // UUID represents a uuid string format
   760  //
   761  // swagger:strfmt uuid
   762  type UUID string
   763  
   764  // MarshalText turns this instance into text
   765  func (u UUID) MarshalText() ([]byte, error) {
   766  	return []byte(string(u)), nil
   767  }
   768  
   769  // UnmarshalText hydrates this instance from text
   770  func (u *UUID) UnmarshalText(data []byte) error { // validation is performed later on
   771  	*u = UUID(string(data))
   772  	return nil
   773  }
   774  
   775  // Scan read a value from a database driver
   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  // MarshalJSON returns the UUID as JSON
   794  func (u UUID) MarshalJSON() ([]byte, error) {
   795  	return json.Marshal(string(u))
   796  }
   797  
   798  // UnmarshalJSON sets the UUID from JSON
   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  // DeepCopyInto copies the receiver and writes its value into out.
   812  func (u *UUID) DeepCopyInto(out *UUID) {
   813  	*out = *u
   814  }
   815  
   816  // DeepCopy copies the receiver into a new UUID.
   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  // UUID3 represents a uuid3 string format
   827  //
   828  // swagger:strfmt uuid3
   829  type UUID3 string
   830  
   831  // MarshalText turns this instance into text
   832  func (u UUID3) MarshalText() ([]byte, error) {
   833  	return []byte(string(u)), nil
   834  }
   835  
   836  // UnmarshalText hydrates this instance from text
   837  func (u *UUID3) UnmarshalText(data []byte) error { // validation is performed later on
   838  	*u = UUID3(string(data))
   839  	return nil
   840  }
   841  
   842  // Scan read a value from a database driver
   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  // MarshalJSON returns the UUID as JSON
   861  func (u UUID3) MarshalJSON() ([]byte, error) {
   862  	return json.Marshal(string(u))
   863  }
   864  
   865  // UnmarshalJSON sets the UUID from JSON
   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  // DeepCopyInto copies the receiver and writes its value into out.
   879  func (u *UUID3) DeepCopyInto(out *UUID3) {
   880  	*out = *u
   881  }
   882  
   883  // DeepCopy copies the receiver into a new UUID3.
   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  // UUID4 represents a uuid4 string format
   894  //
   895  // swagger:strfmt uuid4
   896  type UUID4 string
   897  
   898  // MarshalText turns this instance into text
   899  func (u UUID4) MarshalText() ([]byte, error) {
   900  	return []byte(string(u)), nil
   901  }
   902  
   903  // UnmarshalText hydrates this instance from text
   904  func (u *UUID4) UnmarshalText(data []byte) error { // validation is performed later on
   905  	*u = UUID4(string(data))
   906  	return nil
   907  }
   908  
   909  // Scan read a value from a database driver
   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  // MarshalJSON returns the UUID as JSON
   928  func (u UUID4) MarshalJSON() ([]byte, error) {
   929  	return json.Marshal(string(u))
   930  }
   931  
   932  // UnmarshalJSON sets the UUID from JSON
   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  // DeepCopyInto copies the receiver and writes its value into out.
   946  func (u *UUID4) DeepCopyInto(out *UUID4) {
   947  	*out = *u
   948  }
   949  
   950  // DeepCopy copies the receiver into a new UUID4.
   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  // UUID5 represents a uuid5 string format
   961  //
   962  // swagger:strfmt uuid5
   963  type UUID5 string
   964  
   965  // MarshalText turns this instance into text
   966  func (u UUID5) MarshalText() ([]byte, error) {
   967  	return []byte(string(u)), nil
   968  }
   969  
   970  // UnmarshalText hydrates this instance from text
   971  func (u *UUID5) UnmarshalText(data []byte) error { // validation is performed later on
   972  	*u = UUID5(string(data))
   973  	return nil
   974  }
   975  
   976  // Scan read a value from a database driver
   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  // MarshalJSON returns the UUID as JSON
   995  func (u UUID5) MarshalJSON() ([]byte, error) {
   996  	return json.Marshal(string(u))
   997  }
   998  
   999  // UnmarshalJSON sets the UUID from JSON
  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  // DeepCopyInto copies the receiver and writes its value into out.
  1013  func (u *UUID5) DeepCopyInto(out *UUID5) {
  1014  	*out = *u
  1015  }
  1016  
  1017  // DeepCopy copies the receiver into a new UUID5.
  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  // ISBN represents an isbn string format
  1028  //
  1029  // swagger:strfmt isbn
  1030  type ISBN string
  1031  
  1032  // MarshalText turns this instance into text
  1033  func (u ISBN) MarshalText() ([]byte, error) {
  1034  	return []byte(string(u)), nil
  1035  }
  1036  
  1037  // UnmarshalText hydrates this instance from text
  1038  func (u *ISBN) UnmarshalText(data []byte) error { // validation is performed later on
  1039  	*u = ISBN(string(data))
  1040  	return nil
  1041  }
  1042  
  1043  // Scan read a value from a database driver
  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  // MarshalJSON returns the ISBN as JSON
  1062  func (u ISBN) MarshalJSON() ([]byte, error) {
  1063  	return json.Marshal(string(u))
  1064  }
  1065  
  1066  // UnmarshalJSON sets the ISBN from JSON
  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  // DeepCopyInto copies the receiver and writes its value into out.
  1080  func (u *ISBN) DeepCopyInto(out *ISBN) {
  1081  	*out = *u
  1082  }
  1083  
  1084  // DeepCopy copies the receiver into a new ISBN.
  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  // ISBN10 represents an isbn 10 string format
  1095  //
  1096  // swagger:strfmt isbn10
  1097  type ISBN10 string
  1098  
  1099  // MarshalText turns this instance into text
  1100  func (u ISBN10) MarshalText() ([]byte, error) {
  1101  	return []byte(string(u)), nil
  1102  }
  1103  
  1104  // UnmarshalText hydrates this instance from text
  1105  func (u *ISBN10) UnmarshalText(data []byte) error { // validation is performed later on
  1106  	*u = ISBN10(string(data))
  1107  	return nil
  1108  }
  1109  
  1110  // Scan read a value from a database driver
  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  // MarshalJSON returns the ISBN10 as JSON
  1129  func (u ISBN10) MarshalJSON() ([]byte, error) {
  1130  	return json.Marshal(string(u))
  1131  }
  1132  
  1133  // UnmarshalJSON sets the ISBN10 from JSON
  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  // DeepCopyInto copies the receiver and writes its value into out.
  1147  func (u *ISBN10) DeepCopyInto(out *ISBN10) {
  1148  	*out = *u
  1149  }
  1150  
  1151  // DeepCopy copies the receiver into a new ISBN10.
  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  // ISBN13 represents an isbn 13 string format
  1162  //
  1163  // swagger:strfmt isbn13
  1164  type ISBN13 string
  1165  
  1166  // MarshalText turns this instance into text
  1167  func (u ISBN13) MarshalText() ([]byte, error) {
  1168  	return []byte(string(u)), nil
  1169  }
  1170  
  1171  // UnmarshalText hydrates this instance from text
  1172  func (u *ISBN13) UnmarshalText(data []byte) error { // validation is performed later on
  1173  	*u = ISBN13(string(data))
  1174  	return nil
  1175  }
  1176  
  1177  // Scan read a value from a database driver
  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  // MarshalJSON returns the ISBN13 as JSON
  1196  func (u ISBN13) MarshalJSON() ([]byte, error) {
  1197  	return json.Marshal(string(u))
  1198  }
  1199  
  1200  // UnmarshalJSON sets the ISBN13 from JSON
  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  // DeepCopyInto copies the receiver and writes its value into out.
  1214  func (u *ISBN13) DeepCopyInto(out *ISBN13) {
  1215  	*out = *u
  1216  }
  1217  
  1218  // DeepCopy copies the receiver into a new ISBN13.
  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  // CreditCard represents a credit card string format
  1229  //
  1230  // swagger:strfmt creditcard
  1231  type CreditCard string
  1232  
  1233  // MarshalText turns this instance into text
  1234  func (u CreditCard) MarshalText() ([]byte, error) {
  1235  	return []byte(string(u)), nil
  1236  }
  1237  
  1238  // UnmarshalText hydrates this instance from text
  1239  func (u *CreditCard) UnmarshalText(data []byte) error { // validation is performed later on
  1240  	*u = CreditCard(string(data))
  1241  	return nil
  1242  }
  1243  
  1244  // Scan read a value from a database driver
  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  // MarshalJSON returns the CreditCard as JSON
  1263  func (u CreditCard) MarshalJSON() ([]byte, error) {
  1264  	return json.Marshal(string(u))
  1265  }
  1266  
  1267  // UnmarshalJSON sets the CreditCard from JSON
  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  // DeepCopyInto copies the receiver and writes its value into out.
  1281  func (u *CreditCard) DeepCopyInto(out *CreditCard) {
  1282  	*out = *u
  1283  }
  1284  
  1285  // DeepCopy copies the receiver into a new CreditCard.
  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  // SSN represents a social security string format
  1296  //
  1297  // swagger:strfmt ssn
  1298  type SSN string
  1299  
  1300  // MarshalText turns this instance into text
  1301  func (u SSN) MarshalText() ([]byte, error) {
  1302  	return []byte(string(u)), nil
  1303  }
  1304  
  1305  // UnmarshalText hydrates this instance from text
  1306  func (u *SSN) UnmarshalText(data []byte) error { // validation is performed later on
  1307  	*u = SSN(string(data))
  1308  	return nil
  1309  }
  1310  
  1311  // Scan read a value from a database driver
  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  // MarshalJSON returns the SSN as JSON
  1330  func (u SSN) MarshalJSON() ([]byte, error) {
  1331  	return json.Marshal(string(u))
  1332  }
  1333  
  1334  // UnmarshalJSON sets the SSN from JSON
  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  // DeepCopyInto copies the receiver and writes its value into out.
  1348  func (u *SSN) DeepCopyInto(out *SSN) {
  1349  	*out = *u
  1350  }
  1351  
  1352  // DeepCopy copies the receiver into a new SSN.
  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  // HexColor represents a hex color string format
  1363  //
  1364  // swagger:strfmt hexcolor
  1365  type HexColor string
  1366  
  1367  // MarshalText turns this instance into text
  1368  func (h HexColor) MarshalText() ([]byte, error) {
  1369  	return []byte(string(h)), nil
  1370  }
  1371  
  1372  // UnmarshalText hydrates this instance from text
  1373  func (h *HexColor) UnmarshalText(data []byte) error { // validation is performed later on
  1374  	*h = HexColor(string(data))
  1375  	return nil
  1376  }
  1377  
  1378  // Scan read a value from a database driver
  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  // MarshalJSON returns the HexColor as JSON
  1397  func (h HexColor) MarshalJSON() ([]byte, error) {
  1398  	return json.Marshal(string(h))
  1399  }
  1400  
  1401  // UnmarshalJSON sets the HexColor from JSON
  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  // DeepCopyInto copies the receiver and writes its value into out.
  1415  func (h *HexColor) DeepCopyInto(out *HexColor) {
  1416  	*out = *h
  1417  }
  1418  
  1419  // DeepCopy copies the receiver into a new HexColor.
  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  // RGBColor represents a RGB color string format
  1430  //
  1431  // swagger:strfmt rgbcolor
  1432  type RGBColor string
  1433  
  1434  // MarshalText turns this instance into text
  1435  func (r RGBColor) MarshalText() ([]byte, error) {
  1436  	return []byte(string(r)), nil
  1437  }
  1438  
  1439  // UnmarshalText hydrates this instance from text
  1440  func (r *RGBColor) UnmarshalText(data []byte) error { // validation is performed later on
  1441  	*r = RGBColor(string(data))
  1442  	return nil
  1443  }
  1444  
  1445  // Scan read a value from a database driver
  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  // MarshalJSON returns the RGBColor as JSON
  1464  func (r RGBColor) MarshalJSON() ([]byte, error) {
  1465  	return json.Marshal(string(r))
  1466  }
  1467  
  1468  // UnmarshalJSON sets the RGBColor from JSON
  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  // DeepCopyInto copies the receiver and writes its value into out.
  1482  func (r *RGBColor) DeepCopyInto(out *RGBColor) {
  1483  	*out = *r
  1484  }
  1485  
  1486  // DeepCopy copies the receiver into a new RGBColor.
  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  // Password represents a password.
  1497  // This has no validations and is mainly used as a marker for UI components.
  1498  //
  1499  // swagger:strfmt password
  1500  type Password string
  1501  
  1502  // MarshalText turns this instance into text
  1503  func (r Password) MarshalText() ([]byte, error) {
  1504  	return []byte(string(r)), nil
  1505  }
  1506  
  1507  // UnmarshalText hydrates this instance from text
  1508  func (r *Password) UnmarshalText(data []byte) error { // validation is performed later on
  1509  	*r = Password(string(data))
  1510  	return nil
  1511  }
  1512  
  1513  // Scan read a value from a database driver
  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  // MarshalJSON returns the Password as JSON
  1532  func (r Password) MarshalJSON() ([]byte, error) {
  1533  	return json.Marshal(string(r))
  1534  }
  1535  
  1536  // UnmarshalJSON sets the Password from JSON
  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  // DeepCopyInto copies the receiver and writes its value into out.
  1550  func (r *Password) DeepCopyInto(out *Password) {
  1551  	*out = *r
  1552  }
  1553  
  1554  // DeepCopy copies the receiver into a new Password.
  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  }