// 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" ) // CreatePullReviewOptions CreatePullReviewOptions are options to create a pull review // // swagger:model CreatePullReviewOptions type CreatePullReviewOptions struct { // body Body string `json:"body,omitempty"` // comments Comments []*CreatePullReviewComment `json:"comments"` // commit ID CommitID string `json:"commit_id,omitempty"` // event Event ReviewStateType `json:"event,omitempty"` } // Validate validates this create pull review options func (m *CreatePullReviewOptions) Validate(formats strfmt.Registry) error { var res []error if err := m.validateComments(formats); err != nil { res = append(res, err) } if err := m.validateEvent(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } func (m *CreatePullReviewOptions) validateComments(formats strfmt.Registry) error { if swag.IsZero(m.Comments) { // not required return nil } for i := 0; i < len(m.Comments); i++ { if swag.IsZero(m.Comments[i]) { // not required continue } if m.Comments[i] != nil { if err := m.Comments[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("comments" + "." + strconv.Itoa(i)) } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("comments" + "." + strconv.Itoa(i)) } return err } } } return nil } func (m *CreatePullReviewOptions) validateEvent(formats strfmt.Registry) error { if swag.IsZero(m.Event) { // not required return nil } if err := m.Event.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("event") } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("event") } return err } return nil } // ContextValidate validate this create pull review options based on the context it is used func (m *CreatePullReviewOptions) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error if err := m.contextValidateComments(ctx, formats); err != nil { res = append(res, err) } if err := m.contextValidateEvent(ctx, formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } func (m *CreatePullReviewOptions) contextValidateComments(ctx context.Context, formats strfmt.Registry) error { for i := 0; i < len(m.Comments); i++ { if m.Comments[i] != nil { if swag.IsZero(m.Comments[i]) { // not required return nil } if err := m.Comments[i].ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("comments" + "." + strconv.Itoa(i)) } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("comments" + "." + strconv.Itoa(i)) } return err } } } return nil } func (m *CreatePullReviewOptions) contextValidateEvent(ctx context.Context, formats strfmt.Registry) error { if swag.IsZero(m.Event) { // not required return nil } if err := m.Event.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("event") } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("event") } return err } return nil } // MarshalBinary interface implementation func (m *CreatePullReviewOptions) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } return swag.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *CreatePullReviewOptions) UnmarshalBinary(b []byte) error { var res CreatePullReviewOptions if err := swag.ReadJSON(b, &res); err != nil { return err } *m = res return nil }