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

// VerifyVip Request to verify single vip.
//
// swagger:model verify_vip
type VerifyVip struct {

	// vip
	Vip IP `json:"vip,omitempty" gorm:"primaryKey"`

	// vip type
	VipType VipType `json:"vip_type,omitempty"`
}

// Validate validates this verify vip
func (m *VerifyVip) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *VerifyVip) validateVip(formats strfmt.Registry) error {
	if swag.IsZero(m.Vip) { // not required
		return nil
	}

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

	return nil
}

func (m *VerifyVip) validateVipType(formats strfmt.Registry) error {
	if swag.IsZero(m.VipType) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this verify vip based on the context it is used
func (m *VerifyVip) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *VerifyVip) contextValidateVip(ctx context.Context, formats strfmt.Registry) error {

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

	return nil
}

func (m *VerifyVip) contextValidateVipType(ctx context.Context, formats strfmt.Registry) error {

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

	return nil
}

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

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