go-kimai/models/user_auth_codes.go
2023-01-14 22:44:16 +01:00

163 lines
3.6 KiB
Go

// 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"
"strconv"
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// UserAuthCodes user auth codes
//
// swagger:model UserAuthCodes
type UserAuthCodes struct {
// codes
Codes []*UserAuth `json:"codes"`
// user
User *User `json:"user,omitempty"`
}
// Validate validates this user auth codes
func (m *UserAuthCodes) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateCodes(formats); err != nil {
res = append(res, err)
}
if err := m.validateUser(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *UserAuthCodes) validateCodes(formats strfmt.Registry) error {
if swag.IsZero(m.Codes) { // not required
return nil
}
for i := 0; i < len(m.Codes); i++ {
if swag.IsZero(m.Codes[i]) { // not required
continue
}
if m.Codes[i] != nil {
if err := m.Codes[i].Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("codes" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("codes" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
func (m *UserAuthCodes) validateUser(formats strfmt.Registry) error {
if swag.IsZero(m.User) { // not required
return nil
}
if m.User != nil {
if err := m.User.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("user")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("user")
}
return err
}
}
return nil
}
// ContextValidate validate this user auth codes based on the context it is used
func (m *UserAuthCodes) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateCodes(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateUser(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *UserAuthCodes) contextValidateCodes(ctx context.Context, formats strfmt.Registry) error {
for i := 0; i < len(m.Codes); i++ {
if m.Codes[i] != nil {
if err := m.Codes[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("codes" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("codes" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
func (m *UserAuthCodes) contextValidateUser(ctx context.Context, formats strfmt.Registry) error {
if m.User != nil {
if err := m.User.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("user")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("user")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (m *UserAuthCodes) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *UserAuthCodes) UnmarshalBinary(b []byte) error {
var res UserAuthCodes
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}