// 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" ) // FileCommitResponse FileCommitResponse contains information generated from a Git commit for a repo's file. // // swagger:model FileCommitResponse type FileCommitResponse struct { // created // Format: date-time Created strfmt.DateTime `json:"created,omitempty"` // HTML URL HTMLURL string `json:"html_url,omitempty"` // message Message string `json:"message,omitempty"` // parents Parents []*CommitMeta `json:"parents"` // s h a SHA string `json:"sha,omitempty"` // URL URL string `json:"url,omitempty"` // author Author *CommitUser `json:"author,omitempty"` // committer Committer *CommitUser `json:"committer,omitempty"` // tree Tree *CommitMeta `json:"tree,omitempty"` } // Validate validates this file commit response func (m *FileCommitResponse) Validate(formats strfmt.Registry) error { var res []error if err := m.validateCreated(formats); err != nil { res = append(res, err) } if err := m.validateParents(formats); err != nil { res = append(res, err) } if err := m.validateAuthor(formats); err != nil { res = append(res, err) } if err := m.validateCommitter(formats); err != nil { res = append(res, err) } if err := m.validateTree(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } func (m *FileCommitResponse) validateCreated(formats strfmt.Registry) error { if swag.IsZero(m.Created) { // not required return nil } if err := validate.FormatOf("created", "body", "date-time", m.Created.String(), formats); err != nil { return err } return nil } func (m *FileCommitResponse) validateParents(formats strfmt.Registry) error { if swag.IsZero(m.Parents) { // not required return nil } for i := 0; i < len(m.Parents); i++ { if swag.IsZero(m.Parents[i]) { // not required continue } if m.Parents[i] != nil { if err := m.Parents[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("parents" + "." + strconv.Itoa(i)) } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("parents" + "." + strconv.Itoa(i)) } return err } } } return nil } func (m *FileCommitResponse) validateAuthor(formats strfmt.Registry) error { if swag.IsZero(m.Author) { // not required return nil } if m.Author != nil { if err := m.Author.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("author") } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("author") } return err } } return nil } func (m *FileCommitResponse) validateCommitter(formats strfmt.Registry) error { if swag.IsZero(m.Committer) { // not required return nil } if m.Committer != nil { if err := m.Committer.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("committer") } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("committer") } return err } } return nil } func (m *FileCommitResponse) validateTree(formats strfmt.Registry) error { if swag.IsZero(m.Tree) { // not required return nil } if m.Tree != nil { if err := m.Tree.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("tree") } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("tree") } return err } } return nil } // ContextValidate validate this file commit response based on the context it is used func (m *FileCommitResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error if err := m.contextValidateParents(ctx, formats); err != nil { res = append(res, err) } if err := m.contextValidateAuthor(ctx, formats); err != nil { res = append(res, err) } if err := m.contextValidateCommitter(ctx, formats); err != nil { res = append(res, err) } if err := m.contextValidateTree(ctx, formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } func (m *FileCommitResponse) contextValidateParents(ctx context.Context, formats strfmt.Registry) error { for i := 0; i < len(m.Parents); i++ { if m.Parents[i] != nil { if swag.IsZero(m.Parents[i]) { // not required return nil } if err := m.Parents[i].ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("parents" + "." + strconv.Itoa(i)) } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("parents" + "." + strconv.Itoa(i)) } return err } } } return nil } func (m *FileCommitResponse) contextValidateAuthor(ctx context.Context, formats strfmt.Registry) error { if m.Author != nil { if swag.IsZero(m.Author) { // not required return nil } if err := m.Author.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("author") } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("author") } return err } } return nil } func (m *FileCommitResponse) contextValidateCommitter(ctx context.Context, formats strfmt.Registry) error { if m.Committer != nil { if swag.IsZero(m.Committer) { // not required return nil } if err := m.Committer.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("committer") } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("committer") } return err } } return nil } func (m *FileCommitResponse) contextValidateTree(ctx context.Context, formats strfmt.Registry) error { if m.Tree != nil { if swag.IsZero(m.Tree) { // not required return nil } if err := m.Tree.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("tree") } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("tree") } return err } } return nil } // MarshalBinary interface implementation func (m *FileCommitResponse) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } return swag.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *FileCommitResponse) UnmarshalBinary(b []byte) error { var res FileCommitResponse if err := swag.ReadJSON(b, &res); err != nil { return err } *m = res return nil }