go-kimai/models/user_collection.go

131 lines
2.8 KiB
Go
Raw Permalink Normal View History

2023-01-14 14:14:06 +00:00
// Code generated by go-swagger; DO NOT EDIT.
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 (
"context"
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// UserCollection user collection
//
// swagger:model UserCollection
type UserCollection struct {
// account number
// Max Length: 30
AccountNumber string `json:"accountNumber,omitempty"`
// The user alias will be displayed in the frontend instead of the username
// Max Length: 60
Alias string `json:"alias,omitempty"`
// The assigned color in HTML hex format, eg. #dd1d00
Color string `json:"color,omitempty"`
// enabled
Enabled bool `json:"enabled,omitempty"`
// Internal ID
ID int64 `json:"id,omitempty"`
// username
// Required: true
// Max Length: 60
// Min Length: 2
Username *string `json:"username"`
}
// Validate validates this user collection
func (m *UserCollection) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateAccountNumber(formats); err != nil {
res = append(res, err)
}
if err := m.validateAlias(formats); err != nil {
res = append(res, err)
}
if err := m.validateUsername(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *UserCollection) validateAccountNumber(formats strfmt.Registry) error {
if swag.IsZero(m.AccountNumber) { // not required
return nil
}
if err := validate.MaxLength("accountNumber", "body", m.AccountNumber, 30); err != nil {
return err
}
return nil
}
func (m *UserCollection) validateAlias(formats strfmt.Registry) error {
if swag.IsZero(m.Alias) { // not required
return nil
}
if err := validate.MaxLength("alias", "body", m.Alias, 60); err != nil {
return err
}
return nil
}
func (m *UserCollection) validateUsername(formats strfmt.Registry) error {
if err := validate.Required("username", "body", m.Username); err != nil {
return err
}
if err := validate.MinLength("username", "body", *m.Username, 2); err != nil {
return err
}
if err := validate.MaxLength("username", "body", *m.Username, 60); err != nil {
return err
}
return nil
}
// ContextValidate validates this user collection based on context it is used
func (m *UserCollection) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *UserCollection) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *UserCollection) UnmarshalBinary(b []byte) error {
var res UserCollection
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}