// 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"
)

// ExamplepbStatusCheckResponse examplepb status check response
//
// swagger:model examplepbStatusCheckResponse
type ExamplepbStatusCheckResponse struct {

	// result
	Result string `json:"result,omitempty"`

	// sub2 status
	Sub2Status *ProtoSub2Status `json:"sub2Status,omitempty"`

	// Both Status types used in response
	SubStatus *ProtoSubStatus `json:"subStatus,omitempty"`
}

// Validate validates this examplepb status check response
func (m *ExamplepbStatusCheckResponse) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *ExamplepbStatusCheckResponse) validateSub2Status(formats strfmt.Registry) error {
	if swag.IsZero(m.Sub2Status) { // not required
		return nil
	}

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

			return err
		}
	}

	return nil
}

func (m *ExamplepbStatusCheckResponse) validateSubStatus(formats strfmt.Registry) error {
	if swag.IsZero(m.SubStatus) { // not required
		return nil
	}

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

			return err
		}
	}

	return nil
}

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

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

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

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

func (m *ExamplepbStatusCheckResponse) contextValidateSub2Status(ctx context.Context, formats strfmt.Registry) error {

	if m.Sub2Status != nil {

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

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

			return err
		}
	}

	return nil
}

func (m *ExamplepbStatusCheckResponse) contextValidateSubStatus(ctx context.Context, formats strfmt.Registry) error {

	if m.SubStatus != nil {

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

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

			return err
		}
	}

	return nil
}

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

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