195 lines
4.2 KiB
Go
195 lines
4.2 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"
|
|
|
|
"github.com/go-openapi/errors"
|
|
"github.com/go-openapi/strfmt"
|
|
"github.com/go-openapi/swag"
|
|
"github.com/go-openapi/validate"
|
|
)
|
|
|
|
// ProjectExpanded project expanded
|
|
//
|
|
// swagger:model ProjectExpanded
|
|
type ProjectExpanded struct {
|
|
|
|
// billable
|
|
// Required: true
|
|
Billable *bool `json:"billable"`
|
|
|
|
// The assigned color in HTML hex format, eg. #dd1d00
|
|
Color string `json:"color,omitempty"`
|
|
|
|
// comment
|
|
Comment string `json:"comment,omitempty"`
|
|
|
|
// customer
|
|
// Required: true
|
|
Customer *Customer `json:"customer"`
|
|
|
|
// Whether this project allows booking of global activities
|
|
// Required: true
|
|
GlobalActivities *bool `json:"globalActivities"`
|
|
|
|
// Internal ID
|
|
ID int64 `json:"id,omitempty"`
|
|
|
|
// Project name
|
|
// Required: true
|
|
// Max Length: 150
|
|
// Min Length: 2
|
|
Name *string `json:"name"`
|
|
|
|
// visible
|
|
// Required: true
|
|
Visible *bool `json:"visible"`
|
|
}
|
|
|
|
// Validate validates this project expanded
|
|
func (m *ProjectExpanded) Validate(formats strfmt.Registry) error {
|
|
var res []error
|
|
|
|
if err := m.validateBillable(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateCustomer(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateGlobalActivities(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateName(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateVisible(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if len(res) > 0 {
|
|
return errors.CompositeValidationError(res...)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *ProjectExpanded) validateBillable(formats strfmt.Registry) error {
|
|
|
|
if err := validate.Required("billable", "body", m.Billable); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *ProjectExpanded) validateCustomer(formats strfmt.Registry) error {
|
|
|
|
if err := validate.Required("customer", "body", m.Customer); err != nil {
|
|
return err
|
|
}
|
|
|
|
if m.Customer != nil {
|
|
if err := m.Customer.Validate(formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("customer")
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("customer")
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *ProjectExpanded) validateGlobalActivities(formats strfmt.Registry) error {
|
|
|
|
if err := validate.Required("globalActivities", "body", m.GlobalActivities); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *ProjectExpanded) 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, 150); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *ProjectExpanded) validateVisible(formats strfmt.Registry) error {
|
|
|
|
if err := validate.Required("visible", "body", m.Visible); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// ContextValidate validate this project expanded based on the context it is used
|
|
func (m *ProjectExpanded) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
|
var res []error
|
|
|
|
if err := m.contextValidateCustomer(ctx, formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if len(res) > 0 {
|
|
return errors.CompositeValidationError(res...)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *ProjectExpanded) contextValidateCustomer(ctx context.Context, formats strfmt.Registry) error {
|
|
|
|
if m.Customer != nil {
|
|
if err := m.Customer.ContextValidate(ctx, formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("customer")
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("customer")
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// MarshalBinary interface implementation
|
|
func (m *ProjectExpanded) MarshalBinary() ([]byte, error) {
|
|
if m == nil {
|
|
return nil, nil
|
|
}
|
|
return swag.WriteJSON(m)
|
|
}
|
|
|
|
// UnmarshalBinary interface implementation
|
|
func (m *ProjectExpanded) UnmarshalBinary(b []byte) error {
|
|
var res ProjectExpanded
|
|
if err := swag.ReadJSON(b, &res); err != nil {
|
|
return err
|
|
}
|
|
*m = res
|
|
return nil
|
|
}
|