feat: init
This commit is contained in:
279
models/timesheet_entity.go
Normal file
279
models/timesheet_entity.go
Normal file
@ -0,0 +1,279 @@
|
||||
// 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"
|
||||
)
|
||||
|
||||
// TimesheetEntity timesheet entity
|
||||
//
|
||||
// swagger:model TimesheetEntity
|
||||
type TimesheetEntity struct {
|
||||
|
||||
// activity
|
||||
Activity int64 `json:"activity,omitempty"`
|
||||
|
||||
// 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
|
||||
Project int64 `json:"project,omitempty"`
|
||||
|
||||
// rate
|
||||
// Minimum: 0
|
||||
Rate *float32 `json:"rate,omitempty"`
|
||||
|
||||
// tags
|
||||
Tags []string `json:"tags"`
|
||||
|
||||
// user
|
||||
User int64 `json:"user,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this timesheet entity
|
||||
func (m *TimesheetEntity) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
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.validateRate(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *TimesheetEntity) 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 *TimesheetEntity) validateBillable(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("billable", "body", m.Billable); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *TimesheetEntity) 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 *TimesheetEntity) validateExported(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("exported", "body", m.Exported); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *TimesheetEntity) 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 *TimesheetEntity) 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 *TimesheetEntity) 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 *TimesheetEntity) 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 based on the context it is used
|
||||
func (m *TimesheetEntity) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.contextValidateMetaFields(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *TimesheetEntity) 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
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *TimesheetEntity) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *TimesheetEntity) UnmarshalBinary(b []byte) error {
|
||||
var res TimesheetEntity
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user