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

package modelscapi

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

// GetDecisionsStreamResponseLinks Decisions list
//
// swagger:model GetDecisionsStreamResponseLinks
type GetDecisionsStreamResponseLinks struct {

	// allowlists
	Allowlists []*AllowlistLink `json:"allowlists"`

	// blocklists
	Blocklists []*BlocklistLink `json:"blocklists"`
}

// Validate validates this get decisions stream response links
func (m *GetDecisionsStreamResponseLinks) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *GetDecisionsStreamResponseLinks) validateAllowlists(formats strfmt.Registry) error {
	if swag.IsZero(m.Allowlists) { // not required
		return nil
	}

	for i := 0; i < len(m.Allowlists); i++ {
		if swag.IsZero(m.Allowlists[i]) { // not required
			continue
		}

		if m.Allowlists[i] != nil {
			if err := m.Allowlists[i].Validate(formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("allowlists" + "." + strconv.Itoa(i))
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("allowlists" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

func (m *GetDecisionsStreamResponseLinks) validateBlocklists(formats strfmt.Registry) error {
	if swag.IsZero(m.Blocklists) { // not required
		return nil
	}

	for i := 0; i < len(m.Blocklists); i++ {
		if swag.IsZero(m.Blocklists[i]) { // not required
			continue
		}

		if m.Blocklists[i] != nil {
			if err := m.Blocklists[i].Validate(formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("blocklists" + "." + strconv.Itoa(i))
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("blocklists" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

// ContextValidate validate this get decisions stream response links based on the context it is used
func (m *GetDecisionsStreamResponseLinks) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *GetDecisionsStreamResponseLinks) contextValidateAllowlists(ctx context.Context, formats strfmt.Registry) error {

	for i := 0; i < len(m.Allowlists); i++ {

		if m.Allowlists[i] != nil {

			if swag.IsZero(m.Allowlists[i]) { // not required
				return nil
			}

			if err := m.Allowlists[i].ContextValidate(ctx, formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("allowlists" + "." + strconv.Itoa(i))
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("allowlists" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

func (m *GetDecisionsStreamResponseLinks) contextValidateBlocklists(ctx context.Context, formats strfmt.Registry) error {

	for i := 0; i < len(m.Blocklists); i++ {

		if m.Blocklists[i] != nil {

			if swag.IsZero(m.Blocklists[i]) { // not required
				return nil
			}

			if err := m.Blocklists[i].ContextValidate(ctx, formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("blocklists" + "." + strconv.Itoa(i))
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("blocklists" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

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

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