blob: aaf5c833355a546b8857c7e617c07c82d4b4e45c [file] [log] [blame]
Serge Bazanskicc25bdf2018-10-25 14:02:58 +02001// Code generated by go-swagger; DO NOT EDIT.
2
3// Copyright 2018 The go-netbox Authors.
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
17package models
18
19// This file was generated by the swagger tool.
20// Editing this file might prove futile when you re-run the swagger generate command
21
22import (
23 strfmt "github.com/go-openapi/strfmt"
24
25 "github.com/go-openapi/errors"
26 "github.com/go-openapi/swag"
27 "github.com/go-openapi/validate"
28)
29
30// NestedUser User
31// swagger:model NestedUser
32type NestedUser struct {
33
34 // ID
35 // Read Only: true
36 ID int64 `json:"id,omitempty"`
37
38 // Username
39 //
40 // Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.
41 // Required: true
42 // Max Length: 150
43 // Pattern: ^[\w.@+-]+$
44 Username *string `json:"username"`
45}
46
47// Validate validates this nested user
48func (m *NestedUser) Validate(formats strfmt.Registry) error {
49 var res []error
50
51 if err := m.validateUsername(formats); err != nil {
52 // prop
53 res = append(res, err)
54 }
55
56 if len(res) > 0 {
57 return errors.CompositeValidationError(res...)
58 }
59 return nil
60}
61
62func (m *NestedUser) validateUsername(formats strfmt.Registry) error {
63
64 if err := validate.Required("username", "body", m.Username); err != nil {
65 return err
66 }
67
68 if err := validate.MaxLength("username", "body", string(*m.Username), 150); err != nil {
69 return err
70 }
71
72 if err := validate.Pattern("username", "body", string(*m.Username), `^[\w.@+-]+$`); err != nil {
73 return err
74 }
75
76 return nil
77}
78
79// MarshalBinary interface implementation
80func (m *NestedUser) MarshalBinary() ([]byte, error) {
81 if m == nil {
82 return nil, nil
83 }
84 return swag.WriteJSON(m)
85}
86
87// UnmarshalBinary interface implementation
88func (m *NestedUser) UnmarshalBinary(b []byte) error {
89 var res NestedUser
90 if err := swag.ReadJSON(b, &res); err != nil {
91 return err
92 }
93 *m = res
94 return nil
95}