chronograf/models/user.go

132 lines
2.2 KiB
Go

package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/errors"
"github.com/go-openapi/validate"
)
/*User user
swagger:model User
*/
type User struct {
/* link
*/
Link *Link `json:"link,omitempty"`
/* permissions
Required: true
*/
Permissions *Permissions `json:"permissions"`
/* roles
*/
Roles *Roles `json:"roles,omitempty"`
/* username
Required: true
Max Length: 64
*/
Username *string `json:"username"`
}
// Validate validates this user
func (m *User) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateLink(formats); err != nil {
// prop
res = append(res, err)
}
if err := m.validatePermissions(formats); err != nil {
// prop
res = append(res, err)
}
if err := m.validateRoles(formats); err != nil {
// prop
res = append(res, err)
}
if err := m.validateUsername(formats); err != nil {
// prop
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *User) validateLink(formats strfmt.Registry) error {
if swag.IsZero(m.Link) { // not required
return nil
}
if m.Link != nil {
if err := m.Link.Validate(formats); err != nil {
return err
}
}
return nil
}
func (m *User) validatePermissions(formats strfmt.Registry) error {
if err := validate.Required("permissions", "body", m.Permissions); err != nil {
return err
}
if m.Permissions != nil {
if err := m.Permissions.Validate(formats); err != nil {
return err
}
}
return nil
}
func (m *User) validateRoles(formats strfmt.Registry) error {
if swag.IsZero(m.Roles) { // not required
return nil
}
if m.Roles != nil {
if err := m.Roles.Validate(formats); err != nil {
return err
}
}
return nil
}
func (m *User) validateUsername(formats strfmt.Registry) error {
if err := validate.Required("username", "body", m.Username); err != nil {
return err
}
if err := validate.MaxLength("username", "body", string(*m.Username), 64); err != nil {
return err
}
return nil
}