autogits/bots-common/gitea-generated/models/issue_form_field.go
Adam Majer 598ecbbd5a .
2024-07-07 21:12:40 +02:00

169 lines
3.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"
)
// IssueFormField IssueFormField represents a form field
//
// swagger:model IssueFormField
type IssueFormField struct {
// attributes
Attributes map[string]interface{} `json:"attributes,omitempty"`
// ID
ID string `json:"id,omitempty"`
// validations
Validations map[string]interface{} `json:"validations,omitempty"`
// visible
Visible []IssueFormFieldVisible `json:"visible"`
// type
Type IssueFormFieldType `json:"type,omitempty"`
}
// Validate validates this issue form field
func (m *IssueFormField) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateVisible(formats); err != nil {
res = append(res, err)
}
if err := m.validateType(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *IssueFormField) validateVisible(formats strfmt.Registry) error {
if swag.IsZero(m.Visible) { // not required
return nil
}
for i := 0; i < len(m.Visible); i++ {
if err := m.Visible[i].Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("visible" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("visible" + "." + strconv.Itoa(i))
}
return err
}
}
return nil
}
func (m *IssueFormField) validateType(formats strfmt.Registry) error {
if swag.IsZero(m.Type) { // not required
return nil
}
if err := m.Type.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("type")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("type")
}
return err
}
return nil
}
// ContextValidate validate this issue form field based on the context it is used
func (m *IssueFormField) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateVisible(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateType(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *IssueFormField) contextValidateVisible(ctx context.Context, formats strfmt.Registry) error {
for i := 0; i < len(m.Visible); i++ {
if swag.IsZero(m.Visible[i]) { // not required
return nil
}
if err := m.Visible[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("visible" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("visible" + "." + strconv.Itoa(i))
}
return err
}
}
return nil
}
func (m *IssueFormField) contextValidateType(ctx context.Context, formats strfmt.Registry) error {
if swag.IsZero(m.Type) { // not required
return nil
}
if err := m.Type.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("type")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("type")
}
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *IssueFormField) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *IssueFormField) UnmarshalBinary(b []byte) error {
var res IssueFormField
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}