370 lines
8.2 KiB
Go
370 lines
8.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"
|
|
"strconv"
|
|
|
|
"github.com/go-openapi/errors"
|
|
"github.com/go-openapi/strfmt"
|
|
"github.com/go-openapi/swag"
|
|
"github.com/go-openapi/validate"
|
|
)
|
|
|
|
// TimesheetEntityExpanded timesheet entity expanded
|
|
//
|
|
// swagger:model TimesheetEntityExpanded
|
|
type TimesheetEntityExpanded struct {
|
|
|
|
// activity
|
|
// Required: true
|
|
Activity *ActivityExpanded `json:"activity"`
|
|
|
|
// begin
|
|
// Required: true
|
|
// Format: date-time
|
|
Begin *strfmt.DateTime `json:"begin"`
|
|
|
|
// billable
|
|
// Required: true
|
|
Billable *bool `json:"billable"`
|
|
|
|
// description
|
|
Description string `json:"description,omitempty"`
|
|
|
|
// duration
|
|
Duration int64 `json:"duration,omitempty"`
|
|
|
|
// end
|
|
// Format: date-time
|
|
End strfmt.DateTime `json:"end,omitempty"`
|
|
|
|
// exported
|
|
// Required: true
|
|
Exported *bool `json:"exported"`
|
|
|
|
// fixed rate
|
|
// Minimum: 0
|
|
FixedRate *float32 `json:"fixedRate,omitempty"`
|
|
|
|
// hourly rate
|
|
// Minimum: 0
|
|
HourlyRate *float32 `json:"hourlyRate,omitempty"`
|
|
|
|
// id
|
|
ID int64 `json:"id,omitempty"`
|
|
|
|
// internal rate
|
|
InternalRate float32 `json:"internalRate,omitempty"`
|
|
|
|
// Meta fields
|
|
//
|
|
// All visible meta (custom) fields registered with this timesheet
|
|
MetaFields []*TimesheetMeta `json:"metaFields"`
|
|
|
|
// project
|
|
// Required: true
|
|
Project *ProjectExpanded `json:"project"`
|
|
|
|
// rate
|
|
// Minimum: 0
|
|
Rate *float32 `json:"rate,omitempty"`
|
|
|
|
// tags
|
|
Tags []string `json:"tags"`
|
|
|
|
// user
|
|
User int64 `json:"user,omitempty"`
|
|
}
|
|
|
|
// Validate validates this timesheet entity expanded
|
|
func (m *TimesheetEntityExpanded) Validate(formats strfmt.Registry) error {
|
|
var res []error
|
|
|
|
if err := m.validateActivity(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateBegin(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateBillable(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateEnd(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateExported(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateFixedRate(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateHourlyRate(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateMetaFields(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateProject(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateRate(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if len(res) > 0 {
|
|
return errors.CompositeValidationError(res...)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *TimesheetEntityExpanded) validateActivity(formats strfmt.Registry) error {
|
|
|
|
if err := validate.Required("activity", "body", m.Activity); err != nil {
|
|
return err
|
|
}
|
|
|
|
if m.Activity != nil {
|
|
if err := m.Activity.Validate(formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("activity")
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("activity")
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *TimesheetEntityExpanded) validateBegin(formats strfmt.Registry) error {
|
|
|
|
if err := validate.Required("begin", "body", m.Begin); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := validate.FormatOf("begin", "body", "date-time", m.Begin.String(), formats); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *TimesheetEntityExpanded) validateBillable(formats strfmt.Registry) error {
|
|
|
|
if err := validate.Required("billable", "body", m.Billable); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *TimesheetEntityExpanded) validateEnd(formats strfmt.Registry) error {
|
|
if swag.IsZero(m.End) { // not required
|
|
return nil
|
|
}
|
|
|
|
if err := validate.FormatOf("end", "body", "date-time", m.End.String(), formats); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *TimesheetEntityExpanded) validateExported(formats strfmt.Registry) error {
|
|
|
|
if err := validate.Required("exported", "body", m.Exported); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *TimesheetEntityExpanded) validateFixedRate(formats strfmt.Registry) error {
|
|
if swag.IsZero(m.FixedRate) { // not required
|
|
return nil
|
|
}
|
|
|
|
if err := validate.Minimum("fixedRate", "body", float64(*m.FixedRate), 0, false); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *TimesheetEntityExpanded) validateHourlyRate(formats strfmt.Registry) error {
|
|
if swag.IsZero(m.HourlyRate) { // not required
|
|
return nil
|
|
}
|
|
|
|
if err := validate.Minimum("hourlyRate", "body", float64(*m.HourlyRate), 0, false); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *TimesheetEntityExpanded) validateMetaFields(formats strfmt.Registry) error {
|
|
if swag.IsZero(m.MetaFields) { // not required
|
|
return nil
|
|
}
|
|
|
|
for i := 0; i < len(m.MetaFields); i++ {
|
|
if swag.IsZero(m.MetaFields[i]) { // not required
|
|
continue
|
|
}
|
|
|
|
if m.MetaFields[i] != nil {
|
|
if err := m.MetaFields[i].Validate(formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("metaFields" + "." + strconv.Itoa(i))
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("metaFields" + "." + strconv.Itoa(i))
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *TimesheetEntityExpanded) validateProject(formats strfmt.Registry) error {
|
|
|
|
if err := validate.Required("project", "body", m.Project); err != nil {
|
|
return err
|
|
}
|
|
|
|
if m.Project != nil {
|
|
if err := m.Project.Validate(formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("project")
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("project")
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *TimesheetEntityExpanded) validateRate(formats strfmt.Registry) error {
|
|
if swag.IsZero(m.Rate) { // not required
|
|
return nil
|
|
}
|
|
|
|
if err := validate.Minimum("rate", "body", float64(*m.Rate), 0, false); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// ContextValidate validate this timesheet entity expanded based on the context it is used
|
|
func (m *TimesheetEntityExpanded) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
|
var res []error
|
|
|
|
if err := m.contextValidateActivity(ctx, formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.contextValidateMetaFields(ctx, formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.contextValidateProject(ctx, formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if len(res) > 0 {
|
|
return errors.CompositeValidationError(res...)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *TimesheetEntityExpanded) contextValidateActivity(ctx context.Context, formats strfmt.Registry) error {
|
|
|
|
if m.Activity != nil {
|
|
if err := m.Activity.ContextValidate(ctx, formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("activity")
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("activity")
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *TimesheetEntityExpanded) contextValidateMetaFields(ctx context.Context, formats strfmt.Registry) error {
|
|
|
|
for i := 0; i < len(m.MetaFields); i++ {
|
|
|
|
if m.MetaFields[i] != nil {
|
|
if err := m.MetaFields[i].ContextValidate(ctx, formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("metaFields" + "." + strconv.Itoa(i))
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("metaFields" + "." + strconv.Itoa(i))
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *TimesheetEntityExpanded) contextValidateProject(ctx context.Context, formats strfmt.Registry) error {
|
|
|
|
if m.Project != nil {
|
|
if err := m.Project.ContextValidate(ctx, formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("project")
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("project")
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// MarshalBinary interface implementation
|
|
func (m *TimesheetEntityExpanded) MarshalBinary() ([]byte, error) {
|
|
if m == nil {
|
|
return nil, nil
|
|
}
|
|
return swag.WriteJSON(m)
|
|
}
|
|
|
|
// UnmarshalBinary interface implementation
|
|
func (m *TimesheetEntityExpanded) UnmarshalBinary(b []byte) error {
|
|
var res TimesheetEntityExpanded
|
|
if err := swag.ReadJSON(b, &res); err != nil {
|
|
return err
|
|
}
|
|
*m = res
|
|
return nil
|
|
}
|