// Code generated by go-swagger; DO NOT EDIT.

package models

import (
	"context"
	stderrors "errors"

	"github.com/go-openapi/errors"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag"
)

// ExamplepbRepeatedResponseBodyOutResponse examplepb repeated response body out response
//
// swagger:model examplepbRepeatedResponseBodyOutResponse
type ExamplepbRepeatedResponseBodyOutResponse struct {

	// data
	Data string `json:"data,omitempty"`

	// type
	Type *ResponseResponseType `json:"type,omitempty"`
}

// Validate validates this examplepb repeated response body out response
func (m *ExamplepbRepeatedResponseBodyOutResponse) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateType(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (m *ExamplepbRepeatedResponseBodyOutResponse) validateType(formats strfmt.Registry) error {
	if swag.IsZero(m.Type) { // not required
		return nil
	}

	if m.Type != nil {
		if err := m.Type.Validate(formats); err != nil {
			ve := new(errors.Validation)
			if stderrors.As(err, &ve) {
				return ve.ValidateName("type")
			}
			ce := new(errors.CompositeError)
			if stderrors.As(err, &ce) {
				return ce.ValidateName("type")
			}

			return err
		}
	}

	return nil
}

// ContextValidate validate this examplepb repeated response body out response based on the context it is used
func (m *ExamplepbRepeatedResponseBodyOutResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

	if err := m.contextValidateType(ctx, formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (m *ExamplepbRepeatedResponseBodyOutResponse) contextValidateType(ctx context.Context, formats strfmt.Registry) error {

	if m.Type != nil {

		if swag.IsZero(m.Type) { // not required
			return nil
		}

		if err := m.Type.ContextValidate(ctx, formats); err != nil {
			ve := new(errors.Validation)
			if stderrors.As(err, &ve) {
				return ve.ValidateName("type")
			}
			ce := new(errors.CompositeError)
			if stderrors.As(err, &ce) {
				return ce.ValidateName("type")
			}

			return err
		}
	}

	return nil
}

// MarshalBinary interface implementation
func (m *ExamplepbRepeatedResponseBodyOutResponse) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}

// UnmarshalBinary interface implementation
func (m *ExamplepbRepeatedResponseBodyOutResponse) UnmarshalBinary(b []byte) error {
	var res ExamplepbRepeatedResponseBodyOutResponse
	if err := swag.ReadJSON(b, &res); err != nil {
		return err
	}
	*m = res
	return nil
}
