gtslib/models/search_result.go
decentral1se e4ade9c758
All checks were successful
continuous-integration/drone/push Build is passing
feat: init
2024-07-31 22:47:18 +02:00

187 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"
"strconv"
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// SearchResult SearchResult models a search result.
//
// swagger:model SearchResult
type SearchResult struct {
// accounts
Accounts []*Account `json:"accounts"`
// Slice of strings if api v1, slice of tags if api v2.
Hashtags []interface{} `json:"hashtags"`
// statuses
Statuses []*Status `json:"statuses"`
}
// Validate validates this search result
func (m *SearchResult) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateAccounts(formats); err != nil {
res = append(res, err)
}
if err := m.validateStatuses(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *SearchResult) validateAccounts(formats strfmt.Registry) error {
if swag.IsZero(m.Accounts) { // not required
return nil
}
for i := 0; i < len(m.Accounts); i++ {
if swag.IsZero(m.Accounts[i]) { // not required
continue
}
if m.Accounts[i] != nil {
if err := m.Accounts[i].Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("accounts" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("accounts" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
func (m *SearchResult) validateStatuses(formats strfmt.Registry) error {
if swag.IsZero(m.Statuses) { // not required
return nil
}
for i := 0; i < len(m.Statuses); i++ {
if swag.IsZero(m.Statuses[i]) { // not required
continue
}
if m.Statuses[i] != nil {
if err := m.Statuses[i].Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("statuses" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("statuses" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
// ContextValidate validate this search result based on the context it is used
func (m *SearchResult) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateAccounts(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateStatuses(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *SearchResult) contextValidateAccounts(ctx context.Context, formats strfmt.Registry) error {
for i := 0; i < len(m.Accounts); i++ {
if m.Accounts[i] != nil {
if swag.IsZero(m.Accounts[i]) { // not required
return nil
}
if err := m.Accounts[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("accounts" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("accounts" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
func (m *SearchResult) contextValidateStatuses(ctx context.Context, formats strfmt.Registry) error {
for i := 0; i < len(m.Statuses); i++ {
if m.Statuses[i] != nil {
if swag.IsZero(m.Statuses[i]) { // not required
return nil
}
if err := m.Statuses[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("statuses" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("statuses" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
// MarshalBinary interface implementation
func (m *SearchResult) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *SearchResult) UnmarshalBinary(b []byte) error {
var res SearchResult
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}