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

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

// VaultRadar20230501FilterV2 FilterV2 represents a filter criterion for searching.
//
// swagger:model vault_radar_20230501FilterV2
type VaultRadar20230501FilterV2 struct {

	// exact_match indicates whether the filter should match exactly.
	ExactMatch bool `json:"exact_match,omitempty"`

	// id is the identifier of the field to filter on. E.g., "status" is a valid id when searching events.
	ID string `json:"id,omitempty"`

	// op
	Op *VaultRadar20230501FilterV2Operation `json:"op,omitempty"`

	// value holds the values to filter against. E.g., ["NEW", "NOTIFIED"] for filtering event status.
	Value []interface{} `json:"value"`
}

// Validate validates this vault radar 20230501 filter v2
func (m *VaultRadar20230501FilterV2) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *VaultRadar20230501FilterV2) validateOp(formats strfmt.Registry) error {
	if swag.IsZero(m.Op) { // not required
		return nil
	}

	if m.Op != nil {
		if err := m.Op.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("op")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("op")
			}
			return err
		}
	}

	return nil
}

// ContextValidate validate this vault radar 20230501 filter v2 based on the context it is used
func (m *VaultRadar20230501FilterV2) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

func (m *VaultRadar20230501FilterV2) contextValidateOp(ctx context.Context, formats strfmt.Registry) error {

	if m.Op != nil {

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

		if err := m.Op.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("op")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("op")
			}
			return err
		}
	}

	return nil
}

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

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