| 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 |
"net/mail" |
| 21 |
"regexp" |
| 22 |
"strings" |
| 23 |
|
| 24 |
netutils "k8s.io/utils/net" |
| 25 |
|
| 26 |
"k8s.io/kube-openapi/pkg/internal/third_party/govalidator" |
| 27 |
) |
| 28 |
|
| 29 |
const ( |
| 30 |
// HostnamePattern http://json-schema.org/latest/json-schema-validation.html#anchor114 |
| 31 |
// A string instance is valid against this attribute if it is a valid |
| 32 |
// representation for an Internet host name, as defined by RFC 1034, section 3.1 [RFC1034]. |
| 33 |
// http://tools.ietf.org/html/rfc1034#section-3.5 |
| 34 |
// <digit> ::= any one of the ten digits 0 through 9 |
| 35 |
// var digit = /[0-9]/; |
| 36 |
// <letter> ::= any one of the 52 alphabetic characters A through Z in upper case and a through z in lower case |
| 37 |
// var letter = /[a-zA-Z]/; |
| 38 |
// <let-dig> ::= <letter> | <digit> |
| 39 |
// var letDig = /[0-9a-zA-Z]/; |
| 40 |
// <let-dig-hyp> ::= <let-dig> | "-" |
| 41 |
// var letDigHyp = /[-0-9a-zA-Z]/; |
| 42 |
// <ldh-str> ::= <let-dig-hyp> | <let-dig-hyp> <ldh-str> |
| 43 |
// var ldhStr = /[-0-9a-zA-Z]+/; |
| 44 |
// <label> ::= <letter> [ [ <ldh-str> ] <let-dig> ] |
| 45 |
// var label = /[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?/; |
| 46 |
// <subdomain> ::= <label> | <subdomain> "." <label> |
| 47 |
// var subdomain = /^[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?(\.[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?)*$/; |
| 48 |
// <domain> ::= <subdomain> | " " |
| 49 |
// |
| 50 |
// Additional validations: |
| 51 |
// - for FDQNs, top-level domain (e.g. ".com"), is at least to letters long (no special characters here) |
| 52 |
// - hostnames may start with a digit [RFC1123] |
| 53 |
// - special registered names with an underscore ('_') are not allowed in this context |
| 54 |
// - dashes are permitted, but not at the start or the end of a segment |
| 55 |
// - long top-level domain names (e.g. example.london) are permitted |
| 56 |
// - symbol unicode points are permitted (e.g. emoji) (not for top-level domain) |
| 57 |
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})$` |
| 58 |
// UUIDPattern Regex for UUID that allows uppercase |
| 59 |
UUIDPattern = `(?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}$` |
| 60 |
// UUID3Pattern Regex for UUID3 that allows uppercase |
| 61 |
UUID3Pattern = `(?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?3[0-9a-f]{3}-?[0-9a-f]{4}-?[0-9a-f]{12}$` |
| 62 |
// UUID4Pattern Regex for UUID4 that allows uppercase |
| 63 |
UUID4Pattern = `(?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?4[0-9a-f]{3}-?[89ab][0-9a-f]{3}-?[0-9a-f]{12}$` |
| 64 |
// UUID5Pattern Regex for UUID5 that allows uppercase |
| 65 |
UUID5Pattern = `(?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?5[0-9a-f]{3}-?[89ab][0-9a-f]{3}-?[0-9a-f]{12}$` |
| 66 |
// json null type |
| 67 |
jsonNull = "null" |
| 68 |
) |
| 69 |
|
| 70 |
var ( |
| 71 |
rxHostname = regexp.MustCompile(HostnamePattern) |
| 72 |
rxUUID = regexp.MustCompile(UUIDPattern) |
| 73 |
rxUUID3 = regexp.MustCompile(UUID3Pattern) |
| 74 |
rxUUID4 = regexp.MustCompile(UUID4Pattern) |
| 75 |
rxUUID5 = regexp.MustCompile(UUID5Pattern) |
| 76 |
) |
| 77 |
|
| 78 |
// IsHostname returns true when the string is a valid hostname |
| 79 |
func IsHostname(str string) bool { |
| 80 |
if !rxHostname.MatchString(str) { |
| 81 |
return false |
| 82 |
} |
| 83 |
|
| 84 |
// the sum of all label octets and label lengths is limited to 255. |
| 85 |
if len(str) > 255 { |
| 86 |
return false |
| 87 |
} |
| 88 |
|
| 89 |
// Each node has a label, which is zero to 63 octets in length |
| 90 |
parts := strings.Split(str, ".") |
| 91 |
valid := true |
| 92 |
for _, p := range parts { |
| 93 |
if len(p) > 63 { |
| 94 |
valid = false |
| 95 |
} |
| 96 |
} |
| 97 |
return valid |
| 98 |
} |
| 99 |
|
| 100 |
// IsUUID returns true is the string matches a UUID, upper case is allowed |
| 101 |
func IsUUID(str string) bool { |
| 102 |
return rxUUID.MatchString(str) |
| 103 |
} |
| 104 |
|
| 105 |
// IsUUID3 returns true is the string matches a UUID, upper case is allowed |
| 106 |
func IsUUID3(str string) bool { |
| 107 |
return rxUUID3.MatchString(str) |
| 108 |
} |
| 109 |
|
| 110 |
// IsUUID4 returns true is the string matches a UUID, upper case is allowed |
| 111 |
func IsUUID4(str string) bool { |
| 112 |
return rxUUID4.MatchString(str) |
| 113 |
} |
| 114 |
|
| 115 |
// IsUUID5 returns true is the string matches a UUID, upper case is allowed |
| 116 |
func IsUUID5(str string) bool { |
| 117 |
return rxUUID5.MatchString(str) |
| 118 |
} |
| 119 |
|
| 120 |
// IsEmail validates an email address. |
| 121 |
func IsEmail(str string) bool { |
| 122 |
addr, e := mail.ParseAddress(str) |
| 123 |
return e == nil && addr.Address != "" |
| 124 |
} |
| 125 |
|
| 126 |
func init() { |
| 127 |
// register formats in the default registry: |
| 128 |
// - byte |
| 129 |
// - creditcard |
| 130 |
// - email |
| 131 |
// - hexcolor |
| 132 |
// - hostname |
| 133 |
// - ipv4 |
| 134 |
// - ipv6 |
| 135 |
// - cidr |
| 136 |
// - isbn |
| 137 |
// - isbn10 |
| 138 |
// - isbn13 |
| 139 |
// - mac |
| 140 |
// - password |
| 141 |
// - rgbcolor |
| 142 |
// - ssn |
| 143 |
// - uri |
| 144 |
// - uuid |
| 145 |
// - uuid3 |
| 146 |
// - uuid4 |
| 147 |
// - uuid5 |
| 148 |
u := URI("") |
| 149 |
Default.Add("uri", &u, govalidator.IsRequestURI) |
| 150 |
|
| 151 |
eml := Email("") |
| 152 |
Default.Add("email", &eml, IsEmail) |
| 153 |
|
| 154 |
hn := Hostname("") |
| 155 |
Default.Add("hostname", &hn, IsHostname) |
| 156 |
|
| 157 |
ip4 := IPv4("") |
| 158 |
Default.Add("ipv4", &ip4, isIPv4) |
| 159 |
|
| 160 |
ip6 := IPv6("") |
| 161 |
Default.Add("ipv6", &ip6, govalidator.IsIPv6) |
| 162 |
|
| 163 |
cidr := CIDR("") |
| 164 |
Default.Add("cidr", &cidr, isCIDR) |
| 165 |
|
| 166 |
mac := MAC("") |
| 167 |
Default.Add("mac", &mac, govalidator.IsMAC) |
| 168 |
|
| 169 |
uid := UUID("") |
| 170 |
Default.Add("uuid", &uid, IsUUID) |
| 171 |
|
| 172 |
uid3 := UUID3("") |
| 173 |
Default.Add("uuid3", &uid3, IsUUID3) |
| 174 |
|
| 175 |
uid4 := UUID4("") |
| 176 |
Default.Add("uuid4", &uid4, IsUUID4) |
| 177 |
|
| 178 |
uid5 := UUID5("") |
| 179 |
Default.Add("uuid5", &uid5, IsUUID5) |
| 180 |
|
| 181 |
isbn := ISBN("") |
| 182 |
Default.Add("isbn", &isbn, func(str string) bool { return govalidator.IsISBN10(str) || govalidator.IsISBN13(str) }) |
| 183 |
|
| 184 |
isbn10 := ISBN10("") |
| 185 |
Default.Add("isbn10", &isbn10, govalidator.IsISBN10) |
| 186 |
|
| 187 |
isbn13 := ISBN13("") |
| 188 |
Default.Add("isbn13", &isbn13, govalidator.IsISBN13) |
| 189 |
|
| 190 |
cc := CreditCard("") |
| 191 |
Default.Add("creditcard", &cc, govalidator.IsCreditCard) |
| 192 |
|
| 193 |
ssn := SSN("") |
| 194 |
Default.Add("ssn", &ssn, govalidator.IsSSN) |
| 195 |
|
| 196 |
hc := HexColor("") |
| 197 |
Default.Add("hexcolor", &hc, govalidator.IsHexcolor) |
| 198 |
|
| 199 |
rc := RGBColor("") |
| 200 |
Default.Add("rgbcolor", &rc, govalidator.IsRGBcolor) |
| 201 |
|
| 202 |
b64 := Base64([]byte(nil)) |
| 203 |
Default.Add("byte", &b64, govalidator.IsBase64) |
| 204 |
|
| 205 |
pw := Password("") |
| 206 |
Default.Add("password", &pw, func(_ string) bool { return true }) |
| 207 |
} |
| 208 |
|
| 209 |
// isIPv4 checks if the string is an IPv4 address, tolerating leading 0's for compatibility with go < 1.17. |
| 210 |
func isIPv4(s string) bool { |
| 211 |
ip := netutils.ParseIPSloppy(s) |
| 212 |
return ip != nil && strings.Contains(s, ".") |
| 213 |
} |
| 214 |
|
| 215 |
// isCIDR checks if the string is valid CIDR notation, tolerating leading 0's for compatibility with go < 1.17. |
| 216 |
func isCIDR(s string) bool { |
| 217 |
_, _, err := netutils.ParseCIDRSloppy(s) |
| 218 |
return err == nil |
| 219 |
} |
| 220 |
|
| 221 |
// Base64 represents a base64 encoded string, using URLEncoding alphabet |
| 222 |
// |
| 223 |
// swagger:strfmt byte |
| 224 |
type Base64 []byte |
| 225 |
|
| 226 |
// MarshalText turns this instance into text |
| 227 |
func (b Base64) MarshalText() ([]byte, error) { |
| 228 |
enc := base64.URLEncoding |
| 229 |
src := []byte(b) |
| 230 |
buf := make([]byte, enc.EncodedLen(len(src))) |
| 231 |
enc.Encode(buf, src) |
| 232 |
return buf, nil |
| 233 |
} |
| 234 |
|
| 235 |
// UnmarshalText hydrates this instance from text |
| 236 |
func (b *Base64) UnmarshalText(data []byte) error { // validation is performed later on |
| 237 |
enc := base64.URLEncoding |
| 238 |
dbuf := make([]byte, enc.DecodedLen(len(data))) |
| 239 |
|
| 240 |
n, err := enc.Decode(dbuf, data) |
| 241 |
if err != nil { |
| 242 |
return err |
| 243 |
} |
| 244 |
|
| 245 |
*b = dbuf[:n] |
| 246 |
return nil |
| 247 |
} |
| 248 |
|
| 249 |
func (b Base64) String() string { |
| 250 |
return base64.StdEncoding.EncodeToString([]byte(b)) |
| 251 |
} |
| 252 |
|
| 253 |
// MarshalJSON returns the Base64 as JSON |
| 254 |
func (b Base64) MarshalJSON() ([]byte, error) { |
| 255 |
return json.Marshal(b.String()) |
| 256 |
} |
| 257 |
|
| 258 |
// UnmarshalJSON sets the Base64 from JSON |
| 259 |
func (b *Base64) UnmarshalJSON(data []byte) error { |
| 260 |
var b64str string |
| 261 |
if err := json.Unmarshal(data, &b64str); err != nil { |
| 262 |
return err |
| 263 |
} |
| 264 |
vb, err := base64.StdEncoding.DecodeString(b64str) |
| 265 |
if err != nil { |
| 266 |
return err |
| 267 |
} |
| 268 |
*b = Base64(vb) |
| 269 |
return nil |
| 270 |
} |
| 271 |
|
| 272 |
// DeepCopyInto copies the receiver and writes its value into out. |
| 273 |
func (b *Base64) DeepCopyInto(out *Base64) { |
| 274 |
*out = *b |
| 275 |
} |
| 276 |
|
| 277 |
// DeepCopy copies the receiver into a new Base64. |
| 278 |
func (b *Base64) DeepCopy() *Base64 { |
| 279 |
if b == nil { |
| 280 |
return nil |
| 281 |
} |
| 282 |
out := new(Base64) |
| 283 |
b.DeepCopyInto(out) |
| 284 |
return out |
| 285 |
} |
| 286 |
|
| 287 |
// URI represents the uri string format as specified by the json schema spec |
| 288 |
// |
| 289 |
// swagger:strfmt uri |
| 290 |
type URI string |
| 291 |
|
| 292 |
// MarshalText turns this instance into text |
| 293 |
func (u URI) MarshalText() ([]byte, error) { |
| 294 |
return []byte(string(u)), nil |
| 295 |
} |
| 296 |
|
| 297 |
// UnmarshalText hydrates this instance from text |
| 298 |
func (u *URI) UnmarshalText(data []byte) error { // validation is performed later on |
| 299 |
*u = URI(string(data)) |
| 300 |
return nil |
| 301 |
} |
| 302 |
|
| 303 |
func (u URI) String() string { |
| 304 |
return string(u) |
| 305 |
} |
| 306 |
|
| 307 |
// MarshalJSON returns the URI as JSON |
| 308 |
func (u URI) MarshalJSON() ([]byte, error) { |
| 309 |
return json.Marshal(string(u)) |
| 310 |
} |
| 311 |
|
| 312 |
// UnmarshalJSON sets the URI from JSON |
| 313 |
func (u *URI) UnmarshalJSON(data []byte) error { |
| 314 |
var uristr string |
| 315 |
if err := json.Unmarshal(data, &uristr); err != nil { |
| 316 |
return err |
| 317 |
} |
| 318 |
*u = URI(uristr) |
| 319 |
return nil |
| 320 |
} |
| 321 |
|
| 322 |
// DeepCopyInto copies the receiver and writes its value into out. |
| 323 |
func (u *URI) DeepCopyInto(out *URI) { |
| 324 |
*out = *u |
| 325 |
} |
| 326 |
|
| 327 |
// DeepCopy copies the receiver into a new URI. |
| 328 |
func (u *URI) DeepCopy() *URI { |
| 329 |
if u == nil { |
| 330 |
return nil |
| 331 |
} |
| 332 |
out := new(URI) |
| 333 |
u.DeepCopyInto(out) |
| 334 |
return out |
| 335 |
} |
| 336 |
|
| 337 |
// Email represents the email string format as specified by the json schema spec |
| 338 |
// |
| 339 |
// swagger:strfmt email |
| 340 |
type Email string |
| 341 |
|
| 342 |
// MarshalText turns this instance into text |
| 343 |
func (e Email) MarshalText() ([]byte, error) { |
| 344 |
return []byte(string(e)), nil |
| 345 |
} |
| 346 |
|
| 347 |
// UnmarshalText hydrates this instance from text |
| 348 |
func (e *Email) UnmarshalText(data []byte) error { // validation is performed later on |
| 349 |
*e = Email(string(data)) |
| 350 |
return nil |
| 351 |
} |
| 352 |
|
| 353 |
func (e Email) String() string { |
| 354 |
return string(e) |
| 355 |
} |
| 356 |
|
| 357 |
// MarshalJSON returns the Email as JSON |
| 358 |
func (e Email) MarshalJSON() ([]byte, error) { |
| 359 |
return json.Marshal(string(e)) |
| 360 |
} |
| 361 |
|
| 362 |
// UnmarshalJSON sets the Email from JSON |
| 363 |
func (e *Email) UnmarshalJSON(data []byte) error { |
| 364 |
var estr string |
| 365 |
if err := json.Unmarshal(data, &estr); err != nil { |
| 366 |
return err |
| 367 |
} |
| 368 |
*e = Email(estr) |
| 369 |
return nil |
| 370 |
} |
| 371 |
|
| 372 |
// DeepCopyInto copies the receiver and writes its value into out. |
| 373 |
func (e *Email) DeepCopyInto(out *Email) { |
| 374 |
*out = *e |
| 375 |
} |
| 376 |
|
| 377 |
// DeepCopy copies the receiver into a new Email. |
| 378 |
func (e *Email) DeepCopy() *Email { |
| 379 |
if e == nil { |
| 380 |
return nil |
| 381 |
} |
| 382 |
out := new(Email) |
| 383 |
e.DeepCopyInto(out) |
| 384 |
return out |
| 385 |
} |
| 386 |
|
| 387 |
// Hostname represents the hostname string format as specified by the json schema spec |
| 388 |
// |
| 389 |
// swagger:strfmt hostname |
| 390 |
type Hostname string |
| 391 |
|
| 392 |
// MarshalText turns this instance into text |
| 393 |
func (h Hostname) MarshalText() ([]byte, error) { |
| 394 |
return []byte(string(h)), nil |
| 395 |
} |
| 396 |
|
| 397 |
// UnmarshalText hydrates this instance from text |
| 398 |
func (h *Hostname) UnmarshalText(data []byte) error { // validation is performed later on |
| 399 |
*h = Hostname(string(data)) |
| 400 |
return nil |
| 401 |
} |
| 402 |
|
| 403 |
func (h Hostname) String() string { |
| 404 |
return string(h) |
| 405 |
} |
| 406 |
|
| 407 |
// MarshalJSON returns the Hostname as JSON |
| 408 |
func (h Hostname) MarshalJSON() ([]byte, error) { |
| 409 |
return json.Marshal(string(h)) |
| 410 |
} |
| 411 |
|
| 412 |
// UnmarshalJSON sets the Hostname from JSON |
| 413 |
func (h *Hostname) UnmarshalJSON(data []byte) error { |
| 414 |
var hstr string |
| 415 |
if err := json.Unmarshal(data, &hstr); err != nil { |
| 416 |
return err |
| 417 |
} |
| 418 |
*h = Hostname(hstr) |
| 419 |
return nil |
| 420 |
} |
| 421 |
|
| 422 |
// DeepCopyInto copies the receiver and writes its value into out. |
| 423 |
func (h *Hostname) DeepCopyInto(out *Hostname) { |
| 424 |
*out = *h |
| 425 |
} |
| 426 |
|
| 427 |
// DeepCopy copies the receiver into a new Hostname. |
| 428 |
func (h *Hostname) DeepCopy() *Hostname { |
| 429 |
if h == nil { |
| 430 |
return nil |
| 431 |
} |
| 432 |
out := new(Hostname) |
| 433 |
h.DeepCopyInto(out) |
| 434 |
return out |
| 435 |
} |
| 436 |
|
| 437 |
// IPv4 represents an IP v4 address |
| 438 |
// |
| 439 |
// swagger:strfmt ipv4 |
| 440 |
type IPv4 string |
| 441 |
|
| 442 |
// MarshalText turns this instance into text |
| 443 |
func (u IPv4) MarshalText() ([]byte, error) { |
| 444 |
return []byte(string(u)), nil |
| 445 |
} |
| 446 |
|
| 447 |
// UnmarshalText hydrates this instance from text |
| 448 |
func (u *IPv4) UnmarshalText(data []byte) error { // validation is performed later on |
| 449 |
*u = IPv4(string(data)) |
| 450 |
return nil |
| 451 |
} |
| 452 |
|
| 453 |
func (u IPv4) String() string { |
| 454 |
return string(u) |
| 455 |
} |
| 456 |
|
| 457 |
// MarshalJSON returns the IPv4 as JSON |
| 458 |
func (u IPv4) MarshalJSON() ([]byte, error) { |
| 459 |
return json.Marshal(string(u)) |
| 460 |
} |
| 461 |
|
| 462 |
// UnmarshalJSON sets the IPv4 from JSON |
| 463 |
func (u *IPv4) UnmarshalJSON(data []byte) error { |
| 464 |
var ustr string |
| 465 |
if err := json.Unmarshal(data, &ustr); err != nil { |
| 466 |
return err |
| 467 |
} |
| 468 |
*u = IPv4(ustr) |
| 469 |
return nil |
| 470 |
} |
| 471 |
|
| 472 |
// DeepCopyInto copies the receiver and writes its value into out. |
| 473 |
func (u *IPv4) DeepCopyInto(out *IPv4) { |
| 474 |
*out = *u |
| 475 |
} |
| 476 |
|
| 477 |
// DeepCopy copies the receiver into a new IPv4. |
| 478 |
func (u *IPv4) DeepCopy() *IPv4 { |
| 479 |
if u == nil { |
| 480 |
return nil |
| 481 |
} |
| 482 |
out := new(IPv4) |
| 483 |
u.DeepCopyInto(out) |
| 484 |
return out |
| 485 |
} |
| 486 |
|
| 487 |
// IPv6 represents an IP v6 address |
| 488 |
// |
| 489 |
// swagger:strfmt ipv6 |
| 490 |
type IPv6 string |
| 491 |
|
| 492 |
// MarshalText turns this instance into text |
| 493 |
func (u IPv6) MarshalText() ([]byte, error) { |
| 494 |
return []byte(string(u)), nil |
| 495 |
} |
| 496 |
|
| 497 |
// UnmarshalText hydrates this instance from text |
| 498 |
func (u *IPv6) UnmarshalText(data []byte) error { // validation is performed later on |
| 499 |
*u = IPv6(string(data)) |
| 500 |
return nil |
| 501 |
} |
| 502 |
|
| 503 |
func (u IPv6) String() string { |
| 504 |
return string(u) |
| 505 |
} |
| 506 |
|
| 507 |
// MarshalJSON returns the IPv6 as JSON |
| 508 |
func (u IPv6) MarshalJSON() ([]byte, error) { |
| 509 |
return json.Marshal(string(u)) |
| 510 |
} |
| 511 |
|
| 512 |
// UnmarshalJSON sets the IPv6 from JSON |
| 513 |
func (u *IPv6) UnmarshalJSON(data []byte) error { |
| 514 |
var ustr string |
| 515 |
if err := json.Unmarshal(data, &ustr); err != nil { |
| 516 |
return err |
| 517 |
} |
| 518 |
*u = IPv6(ustr) |
| 519 |
return nil |
| 520 |
} |
| 521 |
|
| 522 |
// DeepCopyInto copies the receiver and writes its value into out. |
| 523 |
func (u *IPv6) DeepCopyInto(out *IPv6) { |
| 524 |
*out = *u |
| 525 |
} |
| 526 |
|
| 527 |
// DeepCopy copies the receiver into a new IPv6. |
| 528 |
func (u *IPv6) DeepCopy() *IPv6 { |
| 529 |
if u == nil { |
| 530 |
return nil |
| 531 |
} |
| 532 |
out := new(IPv6) |
| 533 |
u.DeepCopyInto(out) |
| 534 |
return out |
| 535 |
} |
| 536 |
|
| 537 |
// CIDR represents a Classless Inter-Domain Routing notation |
| 538 |
// |
| 539 |
// swagger:strfmt cidr |
| 540 |
type CIDR string |
| 541 |
|
| 542 |
// MarshalText turns this instance into text |
| 543 |
func (u CIDR) MarshalText() ([]byte, error) { |
| 544 |
return []byte(string(u)), nil |
| 545 |
} |
| 546 |
|
| 547 |
// UnmarshalText hydrates this instance from text |
| 548 |
func (u *CIDR) UnmarshalText(data []byte) error { // validation is performed later on |
| 549 |
*u = CIDR(string(data)) |
| 550 |
return nil |
| 551 |
} |
| 552 |
|
| 553 |
func (u CIDR) String() string { |
| 554 |
return string(u) |
| 555 |
} |
| 556 |
|
| 557 |
// MarshalJSON returns the CIDR as JSON |
| 558 |
func (u CIDR) MarshalJSON() ([]byte, error) { |
| 559 |
return json.Marshal(string(u)) |
| 560 |
} |
| 561 |
|
| 562 |
// UnmarshalJSON sets the CIDR from JSON |
| 563 |
func (u *CIDR) UnmarshalJSON(data []byte) error { |
| 564 |
var ustr string |
| 565 |
if err := json.Unmarshal(data, &ustr); err != nil { |
| 566 |
return err |
| 567 |
} |
| 568 |
*u = CIDR(ustr) |
| 569 |
return nil |
| 570 |
} |
| 571 |
|
| 572 |
// DeepCopyInto copies the receiver and writes its value into out. |
| 573 |
func (u *CIDR) DeepCopyInto(out *CIDR) { |
| 574 |
*out = *u |
| 575 |
} |
| 576 |
|
| 577 |
// DeepCopy copies the receiver into a new CIDR. |
| 578 |
func (u *CIDR) DeepCopy() *CIDR { |
| 579 |
if u == nil { |
| 580 |
return nil |
| 581 |
} |
| 582 |
out := new(CIDR) |
| 583 |
u.DeepCopyInto(out) |
| 584 |
return out |
| 585 |
} |
| 586 |
|
| 587 |
// MAC represents a 48 bit MAC address |
| 588 |
// |
| 589 |
// swagger:strfmt mac |
| 590 |
type MAC string |
| 591 |
|
| 592 |
// MarshalText turns this instance into text |
| 593 |
func (u MAC) MarshalText() ([]byte, error) { |
| 594 |
return []byte(string(u)), nil |
| 595 |
} |
| 596 |
|
| 597 |
// UnmarshalText hydrates this instance from text |
| 598 |
func (u *MAC) UnmarshalText(data []byte) error { // validation is performed later on |
| 599 |
*u = MAC(string(data)) |
| 600 |
return nil |
| 601 |
} |
| 602 |
|
| 603 |
func (u MAC) String() string { |
| 604 |
return string(u) |
| 605 |
} |
| 606 |
|
| 607 |
// MarshalJSON returns the MAC as JSON |
| 608 |
func (u MAC) MarshalJSON() ([]byte, error) { |
| 609 |
return json.Marshal(string(u)) |
| 610 |
} |
| 611 |
|
| 612 |
// UnmarshalJSON sets the MAC from JSON |
| 613 |
func (u *MAC) UnmarshalJSON(data []byte) error { |
| 614 |
var ustr string |
| 615 |
if err := json.Unmarshal(data, &ustr); err != nil { |
| 616 |
return err |
| 617 |
} |
| 618 |
*u = MAC(ustr) |
| 619 |
return nil |
| 620 |
} |
| 621 |
|
| 622 |
// DeepCopyInto copies the receiver and writes its value into out. |
| 623 |
func (u *MAC) DeepCopyInto(out *MAC) { |
| 624 |
*out = *u |
| 625 |
} |
| 626 |
|
| 627 |
// DeepCopy copies the receiver into a new MAC. |
| 628 |
func (u *MAC) DeepCopy() *MAC { |
| 629 |
if u == nil { |
| 630 |
return nil |
| 631 |
} |
| 632 |
out := new(MAC) |
| 633 |
u.DeepCopyInto(out) |
| 634 |
return out |
| 635 |
} |
| 636 |
|
| 637 |
// UUID represents a uuid string format |
| 638 |
// |
| 639 |
// swagger:strfmt uuid |
| 640 |
type UUID string |
| 641 |
|
| 642 |
// MarshalText turns this instance into text |
| 643 |
func (u UUID) MarshalText() ([]byte, error) { |
| 644 |
return []byte(string(u)), nil |
| 645 |
} |
| 646 |
|
| 647 |
// UnmarshalText hydrates this instance from text |
| 648 |
func (u *UUID) UnmarshalText(data []byte) error { // validation is performed later on |
| 649 |
*u = UUID(string(data)) |
| 650 |
return nil |
| 651 |
} |
| 652 |
|
| 653 |
func (u UUID) String() string { |
| 654 |
return string(u) |
| 655 |
} |
| 656 |
|
| 657 |
// MarshalJSON returns the UUID as JSON |
| 658 |
func (u UUID) MarshalJSON() ([]byte, error) { |
| 659 |
return json.Marshal(string(u)) |
| 660 |
} |
| 661 |
|
| 662 |
// UnmarshalJSON sets the UUID from JSON |
| 663 |
func (u *UUID) UnmarshalJSON(data []byte) error { |
| 664 |
if string(data) == jsonNull { |
| 665 |
return nil |
| 666 |
} |
| 667 |
var ustr string |
| 668 |
if err := json.Unmarshal(data, &ustr); err != nil { |
| 669 |
return err |
| 670 |
} |
| 671 |
*u = UUID(ustr) |
| 672 |
return nil |
| 673 |
} |
| 674 |
|
| 675 |
// DeepCopyInto copies the receiver and writes its value into out. |
| 676 |
func (u *UUID) DeepCopyInto(out *UUID) { |
| 677 |
*out = *u |
| 678 |
} |
| 679 |
|
| 680 |
// DeepCopy copies the receiver into a new UUID. |
| 681 |
func (u *UUID) DeepCopy() *UUID { |
| 682 |
if u == nil { |
| 683 |
return nil |
| 684 |
} |
| 685 |
out := new(UUID) |
| 686 |
u.DeepCopyInto(out) |
| 687 |
return out |
| 688 |
} |
| 689 |
|
| 690 |
// UUID3 represents a uuid3 string format |
| 691 |
// |
| 692 |
// swagger:strfmt uuid3 |
| 693 |
type UUID3 string |
| 694 |
|
| 695 |
// MarshalText turns this instance into text |
| 696 |
func (u UUID3) MarshalText() ([]byte, error) { |
| 697 |
return []byte(string(u)), nil |
| 698 |
} |
| 699 |
|
| 700 |
// UnmarshalText hydrates this instance from text |
| 701 |
func (u *UUID3) UnmarshalText(data []byte) error { // validation is performed later on |
| 702 |
*u = UUID3(string(data)) |
| 703 |
return nil |
| 704 |
} |
| 705 |
|
| 706 |
func (u UUID3) String() string { |
| 707 |
return string(u) |
| 708 |
} |
| 709 |
|
| 710 |
// MarshalJSON returns the UUID as JSON |
| 711 |
func (u UUID3) MarshalJSON() ([]byte, error) { |
| 712 |
return json.Marshal(string(u)) |
| 713 |
} |
| 714 |
|
| 715 |
// UnmarshalJSON sets the UUID from JSON |
| 716 |
func (u *UUID3) UnmarshalJSON(data []byte) error { |
| 717 |
if string(data) == jsonNull { |
| 718 |
return nil |
| 719 |
} |
| 720 |
var ustr string |
| 721 |
if err := json.Unmarshal(data, &ustr); err != nil { |
| 722 |
return err |
| 723 |
} |
| 724 |
*u = UUID3(ustr) |
| 725 |
return nil |
| 726 |
} |
| 727 |
|
| 728 |
// DeepCopyInto copies the receiver and writes its value into out. |
| 729 |
func (u *UUID3) DeepCopyInto(out *UUID3) { |
| 730 |
*out = *u |
| 731 |
} |
| 732 |
|
| 733 |
// DeepCopy copies the receiver into a new UUID3. |
| 734 |
func (u *UUID3) DeepCopy() *UUID3 { |
| 735 |
if u == nil { |
| 736 |
return nil |
| 737 |
} |
| 738 |
out := new(UUID3) |
| 739 |
u.DeepCopyInto(out) |
| 740 |
return out |
| 741 |
} |
| 742 |
|
| 743 |
// UUID4 represents a uuid4 string format |
| 744 |
// |
| 745 |
// swagger:strfmt uuid4 |
| 746 |
type UUID4 string |
| 747 |
|
| 748 |
// MarshalText turns this instance into text |
| 749 |
func (u UUID4) MarshalText() ([]byte, error) { |
| 750 |
return []byte(string(u)), nil |
| 751 |
} |
| 752 |
|
| 753 |
// UnmarshalText hydrates this instance from text |
| 754 |
func (u *UUID4) UnmarshalText(data []byte) error { // validation is performed later on |
| 755 |
*u = UUID4(string(data)) |
| 756 |
return nil |
| 757 |
} |
| 758 |
|
| 759 |
func (u UUID4) String() string { |
| 760 |
return string(u) |
| 761 |
} |
| 762 |
|
| 763 |
// MarshalJSON returns the UUID as JSON |
| 764 |
func (u UUID4) MarshalJSON() ([]byte, error) { |
| 765 |
return json.Marshal(string(u)) |
| 766 |
} |
| 767 |
|
| 768 |
// UnmarshalJSON sets the UUID from JSON |
| 769 |
func (u *UUID4) UnmarshalJSON(data []byte) error { |
| 770 |
if string(data) == jsonNull { |
| 771 |
return nil |
| 772 |
} |
| 773 |
var ustr string |
| 774 |
if err := json.Unmarshal(data, &ustr); err != nil { |
| 775 |
return err |
| 776 |
} |
| 777 |
*u = UUID4(ustr) |
| 778 |
return nil |
| 779 |
} |
| 780 |
|
| 781 |
// DeepCopyInto copies the receiver and writes its value into out. |
| 782 |
func (u *UUID4) DeepCopyInto(out *UUID4) { |
| 783 |
*out = *u |
| 784 |
} |
| 785 |
|
| 786 |
// DeepCopy copies the receiver into a new UUID4. |
| 787 |
func (u *UUID4) DeepCopy() *UUID4 { |
| 788 |
if u == nil { |
| 789 |
return nil |
| 790 |
} |
| 791 |
out := new(UUID4) |
| 792 |
u.DeepCopyInto(out) |
| 793 |
return out |
| 794 |
} |
| 795 |
|
| 796 |
// UUID5 represents a uuid5 string format |
| 797 |
// |
| 798 |
// swagger:strfmt uuid5 |
| 799 |
type UUID5 string |
| 800 |
|
| 801 |
// MarshalText turns this instance into text |
| 802 |
func (u UUID5) MarshalText() ([]byte, error) { |
| 803 |
return []byte(string(u)), nil |
| 804 |
} |
| 805 |
|
| 806 |
// UnmarshalText hydrates this instance from text |
| 807 |
func (u *UUID5) UnmarshalText(data []byte) error { // validation is performed later on |
| 808 |
*u = UUID5(string(data)) |
| 809 |
return nil |
| 810 |
} |
| 811 |
|
| 812 |
func (u UUID5) String() string { |
| 813 |
return string(u) |
| 814 |
} |
| 815 |
|
| 816 |
// MarshalJSON returns the UUID as JSON |
| 817 |
func (u UUID5) MarshalJSON() ([]byte, error) { |
| 818 |
return json.Marshal(string(u)) |
| 819 |
} |
| 820 |
|
| 821 |
// UnmarshalJSON sets the UUID from JSON |
| 822 |
func (u *UUID5) UnmarshalJSON(data []byte) error { |
| 823 |
if string(data) == jsonNull { |
| 824 |
return nil |
| 825 |
} |
| 826 |
var ustr string |
| 827 |
if err := json.Unmarshal(data, &ustr); err != nil { |
| 828 |
return err |
| 829 |
} |
| 830 |
*u = UUID5(ustr) |
| 831 |
return nil |
| 832 |
} |
| 833 |
|
| 834 |
// DeepCopyInto copies the receiver and writes its value into out. |
| 835 |
func (u *UUID5) DeepCopyInto(out *UUID5) { |
| 836 |
*out = *u |
| 837 |
} |
| 838 |
|
| 839 |
// DeepCopy copies the receiver into a new UUID5. |
| 840 |
func (u *UUID5) DeepCopy() *UUID5 { |
| 841 |
if u == nil { |
| 842 |
return nil |
| 843 |
} |
| 844 |
out := new(UUID5) |
| 845 |
u.DeepCopyInto(out) |
| 846 |
return out |
| 847 |
} |
| 848 |
|
| 849 |
// ISBN represents an isbn string format |
| 850 |
// |
| 851 |
// swagger:strfmt isbn |
| 852 |
type ISBN string |
| 853 |
|
| 854 |
// MarshalText turns this instance into text |
| 855 |
func (u ISBN) MarshalText() ([]byte, error) { |
| 856 |
return []byte(string(u)), nil |
| 857 |
} |
| 858 |
|
| 859 |
// UnmarshalText hydrates this instance from text |
| 860 |
func (u *ISBN) UnmarshalText(data []byte) error { // validation is performed later on |
| 861 |
*u = ISBN(string(data)) |
| 862 |
return nil |
| 863 |
} |
| 864 |
|
| 865 |
func (u ISBN) String() string { |
| 866 |
return string(u) |
| 867 |
} |
| 868 |
|
| 869 |
// MarshalJSON returns the ISBN as JSON |
| 870 |
func (u ISBN) MarshalJSON() ([]byte, error) { |
| 871 |
return json.Marshal(string(u)) |
| 872 |
} |
| 873 |
|
| 874 |
// UnmarshalJSON sets the ISBN from JSON |
| 875 |
func (u *ISBN) UnmarshalJSON(data []byte) error { |
| 876 |
if string(data) == jsonNull { |
| 877 |
return nil |
| 878 |
} |
| 879 |
var ustr string |
| 880 |
if err := json.Unmarshal(data, &ustr); err != nil { |
| 881 |
return err |
| 882 |
} |
| 883 |
*u = ISBN(ustr) |
| 884 |
return nil |
| 885 |
} |
| 886 |
|
| 887 |
// DeepCopyInto copies the receiver and writes its value into out. |
| 888 |
func (u *ISBN) DeepCopyInto(out *ISBN) { |
| 889 |
*out = *u |
| 890 |
} |
| 891 |
|
| 892 |
// DeepCopy copies the receiver into a new ISBN. |
| 893 |
func (u *ISBN) DeepCopy() *ISBN { |
| 894 |
if u == nil { |
| 895 |
return nil |
| 896 |
} |
| 897 |
out := new(ISBN) |
| 898 |
u.DeepCopyInto(out) |
| 899 |
return out |
| 900 |
} |
| 901 |
|
| 902 |
// ISBN10 represents an isbn 10 string format |
| 903 |
// |
| 904 |
// swagger:strfmt isbn10 |
| 905 |
type ISBN10 string |
| 906 |
|
| 907 |
// MarshalText turns this instance into text |
| 908 |
func (u ISBN10) MarshalText() ([]byte, error) { |
| 909 |
return []byte(string(u)), nil |
| 910 |
} |
| 911 |
|
| 912 |
// UnmarshalText hydrates this instance from text |
| 913 |
func (u *ISBN10) UnmarshalText(data []byte) error { // validation is performed later on |
| 914 |
*u = ISBN10(string(data)) |
| 915 |
return nil |
| 916 |
} |
| 917 |
|
| 918 |
func (u ISBN10) String() string { |
| 919 |
return string(u) |
| 920 |
} |
| 921 |
|
| 922 |
// MarshalJSON returns the ISBN10 as JSON |
| 923 |
func (u ISBN10) MarshalJSON() ([]byte, error) { |
| 924 |
return json.Marshal(string(u)) |
| 925 |
} |
| 926 |
|
| 927 |
// UnmarshalJSON sets the ISBN10 from JSON |
| 928 |
func (u *ISBN10) UnmarshalJSON(data []byte) error { |
| 929 |
if string(data) == jsonNull { |
| 930 |
return nil |
| 931 |
} |
| 932 |
var ustr string |
| 933 |
if err := json.Unmarshal(data, &ustr); err != nil { |
| 934 |
return err |
| 935 |
} |
| 936 |
*u = ISBN10(ustr) |
| 937 |
return nil |
| 938 |
} |
| 939 |
|
| 940 |
// DeepCopyInto copies the receiver and writes its value into out. |
| 941 |
func (u *ISBN10) DeepCopyInto(out *ISBN10) { |
| 942 |
*out = *u |
| 943 |
} |
| 944 |
|
| 945 |
// DeepCopy copies the receiver into a new ISBN10. |
| 946 |
func (u *ISBN10) DeepCopy() *ISBN10 { |
| 947 |
if u == nil { |
| 948 |
return nil |
| 949 |
} |
| 950 |
out := new(ISBN10) |
| 951 |
u.DeepCopyInto(out) |
| 952 |
return out |
| 953 |
} |
| 954 |
|
| 955 |
// ISBN13 represents an isbn 13 string format |
| 956 |
// |
| 957 |
// swagger:strfmt isbn13 |
| 958 |
type ISBN13 string |
| 959 |
|
| 960 |
// MarshalText turns this instance into text |
| 961 |
func (u ISBN13) MarshalText() ([]byte, error) { |
| 962 |
return []byte(string(u)), nil |
| 963 |
} |
| 964 |
|
| 965 |
// UnmarshalText hydrates this instance from text |
| 966 |
func (u *ISBN13) UnmarshalText(data []byte) error { // validation is performed later on |
| 967 |
*u = ISBN13(string(data)) |
| 968 |
return nil |
| 969 |
} |
| 970 |
|
| 971 |
func (u ISBN13) String() string { |
| 972 |
return string(u) |
| 973 |
} |
| 974 |
|
| 975 |
// MarshalJSON returns the ISBN13 as JSON |
| 976 |
func (u ISBN13) MarshalJSON() ([]byte, error) { |
| 977 |
return json.Marshal(string(u)) |
| 978 |
} |
| 979 |
|
| 980 |
// UnmarshalJSON sets the ISBN13 from JSON |
| 981 |
func (u *ISBN13) UnmarshalJSON(data []byte) error { |
| 982 |
if string(data) == jsonNull { |
| 983 |
return nil |
| 984 |
} |
| 985 |
var ustr string |
| 986 |
if err := json.Unmarshal(data, &ustr); err != nil { |
| 987 |
return err |
| 988 |
} |
| 989 |
*u = ISBN13(ustr) |
| 990 |
return nil |
| 991 |
} |
| 992 |
|
| 993 |
// DeepCopyInto copies the receiver and writes its value into out. |
| 994 |
func (u *ISBN13) DeepCopyInto(out *ISBN13) { |
| 995 |
*out = *u |
| 996 |
} |
| 997 |
|
| 998 |
// DeepCopy copies the receiver into a new ISBN13. |
| 999 |
func (u *ISBN13) DeepCopy() *ISBN13 { |
| 1000 |
if u == nil { |
| 1001 |
return nil |
| 1002 |
} |
| 1003 |
out := new(ISBN13) |
| 1004 |
u.DeepCopyInto(out) |
| 1005 |
return out |
| 1006 |
} |
| 1007 |
|
| 1008 |
// CreditCard represents a credit card string format |
| 1009 |
// |
| 1010 |
// swagger:strfmt creditcard |
| 1011 |
type CreditCard string |
| 1012 |
|
| 1013 |
// MarshalText turns this instance into text |
| 1014 |
func (u CreditCard) MarshalText() ([]byte, error) { |
| 1015 |
return []byte(string(u)), nil |
| 1016 |
} |
| 1017 |
|
| 1018 |
// UnmarshalText hydrates this instance from text |
| 1019 |
func (u *CreditCard) UnmarshalText(data []byte) error { // validation is performed later on |
| 1020 |
*u = CreditCard(string(data)) |
| 1021 |
return nil |
| 1022 |
} |
| 1023 |
|
| 1024 |
func (u CreditCard) String() string { |
| 1025 |
return string(u) |
| 1026 |
} |
| 1027 |
|
| 1028 |
// MarshalJSON returns the CreditCard as JSON |
| 1029 |
func (u CreditCard) MarshalJSON() ([]byte, error) { |
| 1030 |
return json.Marshal(string(u)) |
| 1031 |
} |
| 1032 |
|
| 1033 |
// UnmarshalJSON sets the CreditCard from JSON |
| 1034 |
func (u *CreditCard) UnmarshalJSON(data []byte) error { |
| 1035 |
if string(data) == jsonNull { |
| 1036 |
return nil |
| 1037 |
} |
| 1038 |
var ustr string |
| 1039 |
if err := json.Unmarshal(data, &ustr); err != nil { |
| 1040 |
return err |
| 1041 |
} |
| 1042 |
*u = CreditCard(ustr) |
| 1043 |
return nil |
| 1044 |
} |
| 1045 |
|
| 1046 |
// DeepCopyInto copies the receiver and writes its value into out. |
| 1047 |
func (u *CreditCard) DeepCopyInto(out *CreditCard) { |
| 1048 |
*out = *u |
| 1049 |
} |
| 1050 |
|
| 1051 |
// DeepCopy copies the receiver into a new CreditCard. |
| 1052 |
func (u *CreditCard) DeepCopy() *CreditCard { |
| 1053 |
if u == nil { |
| 1054 |
return nil |
| 1055 |
} |
| 1056 |
out := new(CreditCard) |
| 1057 |
u.DeepCopyInto(out) |
| 1058 |
return out |
| 1059 |
} |
| 1060 |
|
| 1061 |
// SSN represents a social security string format |
| 1062 |
// |
| 1063 |
// swagger:strfmt ssn |
| 1064 |
type SSN string |
| 1065 |
|
| 1066 |
// MarshalText turns this instance into text |
| 1067 |
func (u SSN) MarshalText() ([]byte, error) { |
| 1068 |
return []byte(string(u)), nil |
| 1069 |
} |
| 1070 |
|
| 1071 |
// UnmarshalText hydrates this instance from text |
| 1072 |
func (u *SSN) UnmarshalText(data []byte) error { // validation is performed later on |
| 1073 |
*u = SSN(string(data)) |
| 1074 |
return nil |
| 1075 |
} |
| 1076 |
|
| 1077 |
func (u SSN) String() string { |
| 1078 |
return string(u) |
| 1079 |
} |
| 1080 |
|
| 1081 |
// MarshalJSON returns the SSN as JSON |
| 1082 |
func (u SSN) MarshalJSON() ([]byte, error) { |
| 1083 |
return json.Marshal(string(u)) |
| 1084 |
} |
| 1085 |
|
| 1086 |
// UnmarshalJSON sets the SSN from JSON |
| 1087 |
func (u *SSN) UnmarshalJSON(data []byte) error { |
| 1088 |
if string(data) == jsonNull { |
| 1089 |
return nil |
| 1090 |
} |
| 1091 |
var ustr string |
| 1092 |
if err := json.Unmarshal(data, &ustr); err != nil { |
| 1093 |
return err |
| 1094 |
} |
| 1095 |
*u = SSN(ustr) |
| 1096 |
return nil |
| 1097 |
} |
| 1098 |
|
| 1099 |
// DeepCopyInto copies the receiver and writes its value into out. |
| 1100 |
func (u *SSN) DeepCopyInto(out *SSN) { |
| 1101 |
*out = *u |
| 1102 |
} |
| 1103 |
|
| 1104 |
// DeepCopy copies the receiver into a new SSN. |
| 1105 |
func (u *SSN) DeepCopy() *SSN { |
| 1106 |
if u == nil { |
| 1107 |
return nil |
| 1108 |
} |
| 1109 |
out := new(SSN) |
| 1110 |
u.DeepCopyInto(out) |
| 1111 |
return out |
| 1112 |
} |
| 1113 |
|
| 1114 |
// HexColor represents a hex color string format |
| 1115 |
// |
| 1116 |
// swagger:strfmt hexcolor |
| 1117 |
type HexColor string |
| 1118 |
|
| 1119 |
// MarshalText turns this instance into text |
| 1120 |
func (h HexColor) MarshalText() ([]byte, error) { |
| 1121 |
return []byte(string(h)), nil |
| 1122 |
} |
| 1123 |
|
| 1124 |
// UnmarshalText hydrates this instance from text |
| 1125 |
func (h *HexColor) UnmarshalText(data []byte) error { // validation is performed later on |
| 1126 |
*h = HexColor(string(data)) |
| 1127 |
return nil |
| 1128 |
} |
| 1129 |
|
| 1130 |
func (h HexColor) String() string { |
| 1131 |
return string(h) |
| 1132 |
} |
| 1133 |
|
| 1134 |
// MarshalJSON returns the HexColor as JSON |
| 1135 |
func (h HexColor) MarshalJSON() ([]byte, error) { |
| 1136 |
return json.Marshal(string(h)) |
| 1137 |
} |
| 1138 |
|
| 1139 |
// UnmarshalJSON sets the HexColor from JSON |
| 1140 |
func (h *HexColor) UnmarshalJSON(data []byte) error { |
| 1141 |
if string(data) == jsonNull { |
| 1142 |
return nil |
| 1143 |
} |
| 1144 |
var ustr string |
| 1145 |
if err := json.Unmarshal(data, &ustr); err != nil { |
| 1146 |
return err |
| 1147 |
} |
| 1148 |
*h = HexColor(ustr) |
| 1149 |
return nil |
| 1150 |
} |
| 1151 |
|
| 1152 |
// DeepCopyInto copies the receiver and writes its value into out. |
| 1153 |
func (h *HexColor) DeepCopyInto(out *HexColor) { |
| 1154 |
*out = *h |
| 1155 |
} |
| 1156 |
|
| 1157 |
// DeepCopy copies the receiver into a new HexColor. |
| 1158 |
func (h *HexColor) DeepCopy() *HexColor { |
| 1159 |
if h == nil { |
| 1160 |
return nil |
| 1161 |
} |
| 1162 |
out := new(HexColor) |
| 1163 |
h.DeepCopyInto(out) |
| 1164 |
return out |
| 1165 |
} |
| 1166 |
|
| 1167 |
// RGBColor represents a RGB color string format |
| 1168 |
// |
| 1169 |
// swagger:strfmt rgbcolor |
| 1170 |
type RGBColor string |
| 1171 |
|
| 1172 |
// MarshalText turns this instance into text |
| 1173 |
func (r RGBColor) MarshalText() ([]byte, error) { |
| 1174 |
return []byte(string(r)), nil |
| 1175 |
} |
| 1176 |
|
| 1177 |
// UnmarshalText hydrates this instance from text |
| 1178 |
func (r *RGBColor) UnmarshalText(data []byte) error { // validation is performed later on |
| 1179 |
*r = RGBColor(string(data)) |
| 1180 |
return nil |
| 1181 |
} |
| 1182 |
|
| 1183 |
func (r RGBColor) String() string { |
| 1184 |
return string(r) |
| 1185 |
} |
| 1186 |
|
| 1187 |
// MarshalJSON returns the RGBColor as JSON |
| 1188 |
func (r RGBColor) MarshalJSON() ([]byte, error) { |
| 1189 |
return json.Marshal(string(r)) |
| 1190 |
} |
| 1191 |
|
| 1192 |
// UnmarshalJSON sets the RGBColor from JSON |
| 1193 |
func (r *RGBColor) UnmarshalJSON(data []byte) error { |
| 1194 |
if string(data) == jsonNull { |
| 1195 |
return nil |
| 1196 |
} |
| 1197 |
var ustr string |
| 1198 |
if err := json.Unmarshal(data, &ustr); err != nil { |
| 1199 |
return err |
| 1200 |
} |
| 1201 |
*r = RGBColor(ustr) |
| 1202 |
return nil |
| 1203 |
} |
| 1204 |
|
| 1205 |
// DeepCopyInto copies the receiver and writes its value into out. |
| 1206 |
func (r *RGBColor) DeepCopyInto(out *RGBColor) { |
| 1207 |
*out = *r |
| 1208 |
} |
| 1209 |
|
| 1210 |
// DeepCopy copies the receiver into a new RGBColor. |
| 1211 |
func (r *RGBColor) DeepCopy() *RGBColor { |
| 1212 |
if r == nil { |
| 1213 |
return nil |
| 1214 |
} |
| 1215 |
out := new(RGBColor) |
| 1216 |
r.DeepCopyInto(out) |
| 1217 |
return out |
| 1218 |
} |
| 1219 |
|
| 1220 |
// Password represents a password. |
| 1221 |
// This has no validations and is mainly used as a marker for UI components. |
| 1222 |
// |
| 1223 |
// swagger:strfmt password |
| 1224 |
type Password string |
| 1225 |
|
| 1226 |
// MarshalText turns this instance into text |
| 1227 |
func (r Password) MarshalText() ([]byte, error) { |
| 1228 |
return []byte(string(r)), nil |
| 1229 |
} |
| 1230 |
|
| 1231 |
// UnmarshalText hydrates this instance from text |
| 1232 |
func (r *Password) UnmarshalText(data []byte) error { // validation is performed later on |
| 1233 |
*r = Password(string(data)) |
| 1234 |
return nil |
| 1235 |
} |
| 1236 |
|
| 1237 |
func (r Password) String() string { |
| 1238 |
return string(r) |
| 1239 |
} |
| 1240 |
|
| 1241 |
// MarshalJSON returns the Password as JSON |
| 1242 |
func (r Password) MarshalJSON() ([]byte, error) { |
| 1243 |
return json.Marshal(string(r)) |
| 1244 |
} |
| 1245 |
|
| 1246 |
// UnmarshalJSON sets the Password from JSON |
| 1247 |
func (r *Password) UnmarshalJSON(data []byte) error { |
| 1248 |
if string(data) == jsonNull { |
| 1249 |
return nil |
| 1250 |
} |
| 1251 |
var ustr string |
| 1252 |
if err := json.Unmarshal(data, &ustr); err != nil { |
| 1253 |
return err |
| 1254 |
} |
| 1255 |
*r = Password(ustr) |
| 1256 |
return nil |
| 1257 |
} |
| 1258 |
|
| 1259 |
// DeepCopyInto copies the receiver and writes its value into out. |
| 1260 |
func (r *Password) DeepCopyInto(out *Password) { |
| 1261 |
*out = *r |
| 1262 |
} |
| 1263 |
|
| 1264 |
// DeepCopy copies the receiver into a new Password. |
| 1265 |
func (r *Password) DeepCopy() *Password { |
| 1266 |
if r == nil { |
| 1267 |
return nil |
| 1268 |
} |
| 1269 |
out := new(Password) |
| 1270 |
r.DeepCopyInto(out) |
| 1271 |
return out |
| 1272 |
} |