// 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"
	stderrors "errors"

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

// BadgeServiceIssueBadgeBody badge service issue badge body
//
// swagger:model BadgeServiceIssueBadgeBody
type BadgeServiceIssueBadgeBody struct {

	// The A2A badge.
	A2a *V1alpha1IssueA2ABadgeRequest `json:"a2a,omitempty"`

	// The MCP badge.
	Mcp *V1alpha1IssueMcpBadgeRequest `json:"mcp,omitempty"`

	// The OASF badge.
	Oasf *V1alpha1IssueOASFBadgeRequest `json:"oasf,omitempty"`
}

// Validate validates this badge service issue badge body
func (m *BadgeServiceIssueBadgeBody) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

func (m *BadgeServiceIssueBadgeBody) validateA2a(formats strfmt.Registry) error {
	if swag.IsZero(m.A2a) { // not required
		return nil
	}

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

			return err
		}
	}

	return nil
}

func (m *BadgeServiceIssueBadgeBody) validateMcp(formats strfmt.Registry) error {
	if swag.IsZero(m.Mcp) { // not required
		return nil
	}

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

			return err
		}
	}

	return nil
}

func (m *BadgeServiceIssueBadgeBody) validateOasf(formats strfmt.Registry) error {
	if swag.IsZero(m.Oasf) { // not required
		return nil
	}

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

			return err
		}
	}

	return nil
}

// ContextValidate validate this badge service issue badge body based on the context it is used
func (m *BadgeServiceIssueBadgeBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

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

func (m *BadgeServiceIssueBadgeBody) contextValidateA2a(ctx context.Context, formats strfmt.Registry) error {

	if m.A2a != nil {

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

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

			return err
		}
	}

	return nil
}

func (m *BadgeServiceIssueBadgeBody) contextValidateMcp(ctx context.Context, formats strfmt.Registry) error {

	if m.Mcp != nil {

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

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

			return err
		}
	}

	return nil
}

func (m *BadgeServiceIssueBadgeBody) contextValidateOasf(ctx context.Context, formats strfmt.Registry) error {

	if m.Oasf != nil {

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

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

			return err
		}
	}

	return nil
}

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

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