432 lines
9.8 KiB
Go
432 lines
9.8 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"
|
|
"github.com/go-openapi/validate"
|
|
)
|
|
|
|
// Team team
|
|
//
|
|
// swagger:model Team
|
|
type Team struct {
|
|
|
|
// Activities assigned to the team
|
|
Activities []*Activity `json:"activities"`
|
|
|
|
// The assigned color in HTML hex format, eg. #dd1d00
|
|
Color string `json:"color,omitempty"`
|
|
|
|
// Customers assigned to the team
|
|
Customers []*Customer `json:"customers"`
|
|
|
|
// id
|
|
ID int64 `json:"id,omitempty"`
|
|
|
|
// All team member (including team leads)
|
|
// Min Items: 1
|
|
Members []*TeamMember `json:"members"`
|
|
|
|
// Team name
|
|
// Required: true
|
|
// Max Length: 100
|
|
// Min Length: 2
|
|
Name *string `json:"name"`
|
|
|
|
// Projects assigned to the team
|
|
Projects []*Project `json:"projects"`
|
|
|
|
// teamlead
|
|
Teamlead *User `json:"teamlead,omitempty"`
|
|
|
|
// Returns all users in the team, both teamlead and normal member.
|
|
Users []*User `json:"users"`
|
|
}
|
|
|
|
// Validate validates this team
|
|
func (m *Team) Validate(formats strfmt.Registry) error {
|
|
var res []error
|
|
|
|
if err := m.validateActivities(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateCustomers(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateMembers(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateName(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateProjects(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateTeamlead(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateUsers(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if len(res) > 0 {
|
|
return errors.CompositeValidationError(res...)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *Team) validateActivities(formats strfmt.Registry) error {
|
|
if swag.IsZero(m.Activities) { // not required
|
|
return nil
|
|
}
|
|
|
|
for i := 0; i < len(m.Activities); i++ {
|
|
if swag.IsZero(m.Activities[i]) { // not required
|
|
continue
|
|
}
|
|
|
|
if m.Activities[i] != nil {
|
|
if err := m.Activities[i].Validate(formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("activities" + "." + strconv.Itoa(i))
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("activities" + "." + strconv.Itoa(i))
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Team) validateCustomers(formats strfmt.Registry) error {
|
|
if swag.IsZero(m.Customers) { // not required
|
|
return nil
|
|
}
|
|
|
|
for i := 0; i < len(m.Customers); i++ {
|
|
if swag.IsZero(m.Customers[i]) { // not required
|
|
continue
|
|
}
|
|
|
|
if m.Customers[i] != nil {
|
|
if err := m.Customers[i].Validate(formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("customers" + "." + strconv.Itoa(i))
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("customers" + "." + strconv.Itoa(i))
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Team) validateMembers(formats strfmt.Registry) error {
|
|
if swag.IsZero(m.Members) { // not required
|
|
return nil
|
|
}
|
|
|
|
iMembersSize := int64(len(m.Members))
|
|
|
|
if err := validate.MinItems("members", "body", iMembersSize, 1); err != nil {
|
|
return err
|
|
}
|
|
|
|
for i := 0; i < len(m.Members); i++ {
|
|
if swag.IsZero(m.Members[i]) { // not required
|
|
continue
|
|
}
|
|
|
|
if m.Members[i] != nil {
|
|
if err := m.Members[i].Validate(formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("members" + "." + strconv.Itoa(i))
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("members" + "." + strconv.Itoa(i))
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Team) validateName(formats strfmt.Registry) error {
|
|
|
|
if err := validate.Required("name", "body", m.Name); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := validate.MinLength("name", "body", *m.Name, 2); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := validate.MaxLength("name", "body", *m.Name, 100); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Team) validateProjects(formats strfmt.Registry) error {
|
|
if swag.IsZero(m.Projects) { // not required
|
|
return nil
|
|
}
|
|
|
|
for i := 0; i < len(m.Projects); i++ {
|
|
if swag.IsZero(m.Projects[i]) { // not required
|
|
continue
|
|
}
|
|
|
|
if m.Projects[i] != nil {
|
|
if err := m.Projects[i].Validate(formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("projects" + "." + strconv.Itoa(i))
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("projects" + "." + strconv.Itoa(i))
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Team) validateTeamlead(formats strfmt.Registry) error {
|
|
if swag.IsZero(m.Teamlead) { // not required
|
|
return nil
|
|
}
|
|
|
|
if m.Teamlead != nil {
|
|
if err := m.Teamlead.Validate(formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("teamlead")
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("teamlead")
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Team) validateUsers(formats strfmt.Registry) error {
|
|
if swag.IsZero(m.Users) { // not required
|
|
return nil
|
|
}
|
|
|
|
for i := 0; i < len(m.Users); i++ {
|
|
if swag.IsZero(m.Users[i]) { // not required
|
|
continue
|
|
}
|
|
|
|
if m.Users[i] != nil {
|
|
if err := m.Users[i].Validate(formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("users" + "." + strconv.Itoa(i))
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("users" + "." + strconv.Itoa(i))
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// ContextValidate validate this team based on the context it is used
|
|
func (m *Team) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
|
var res []error
|
|
|
|
if err := m.contextValidateActivities(ctx, formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.contextValidateCustomers(ctx, formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.contextValidateMembers(ctx, formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.contextValidateProjects(ctx, formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.contextValidateTeamlead(ctx, formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.contextValidateUsers(ctx, formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if len(res) > 0 {
|
|
return errors.CompositeValidationError(res...)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *Team) contextValidateActivities(ctx context.Context, formats strfmt.Registry) error {
|
|
|
|
for i := 0; i < len(m.Activities); i++ {
|
|
|
|
if m.Activities[i] != nil {
|
|
if err := m.Activities[i].ContextValidate(ctx, formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("activities" + "." + strconv.Itoa(i))
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("activities" + "." + strconv.Itoa(i))
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Team) contextValidateCustomers(ctx context.Context, formats strfmt.Registry) error {
|
|
|
|
for i := 0; i < len(m.Customers); i++ {
|
|
|
|
if m.Customers[i] != nil {
|
|
if err := m.Customers[i].ContextValidate(ctx, formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("customers" + "." + strconv.Itoa(i))
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("customers" + "." + strconv.Itoa(i))
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Team) contextValidateMembers(ctx context.Context, formats strfmt.Registry) error {
|
|
|
|
for i := 0; i < len(m.Members); i++ {
|
|
|
|
if m.Members[i] != nil {
|
|
if err := m.Members[i].ContextValidate(ctx, formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("members" + "." + strconv.Itoa(i))
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("members" + "." + strconv.Itoa(i))
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Team) contextValidateProjects(ctx context.Context, formats strfmt.Registry) error {
|
|
|
|
for i := 0; i < len(m.Projects); i++ {
|
|
|
|
if m.Projects[i] != nil {
|
|
if err := m.Projects[i].ContextValidate(ctx, formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("projects" + "." + strconv.Itoa(i))
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("projects" + "." + strconv.Itoa(i))
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Team) contextValidateTeamlead(ctx context.Context, formats strfmt.Registry) error {
|
|
|
|
if m.Teamlead != nil {
|
|
if err := m.Teamlead.ContextValidate(ctx, formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("teamlead")
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("teamlead")
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Team) contextValidateUsers(ctx context.Context, formats strfmt.Registry) error {
|
|
|
|
for i := 0; i < len(m.Users); i++ {
|
|
|
|
if m.Users[i] != nil {
|
|
if err := m.Users[i].ContextValidate(ctx, formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("users" + "." + strconv.Itoa(i))
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("users" + "." + strconv.Itoa(i))
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// MarshalBinary interface implementation
|
|
func (m *Team) MarshalBinary() ([]byte, error) {
|
|
if m == nil {
|
|
return nil, nil
|
|
}
|
|
return swag.WriteJSON(m)
|
|
}
|
|
|
|
// UnmarshalBinary interface implementation
|
|
func (m *Team) UnmarshalBinary(b []byte) error {
|
|
var res Team
|
|
if err := swag.ReadJSON(b, &res); err != nil {
|
|
return err
|
|
}
|
|
*m = res
|
|
return nil
|
|
}
|