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

// VerifiedVip Single VIP verification result.
//
// swagger:model verified_vip
type VerifiedVip struct {

	// verification
	Verification *VipVerification `json:"verification,omitempty"`

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

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

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

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

	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 *VerifiedVip) validateVerification(formats strfmt.Registry) error {
	if swag.IsZero(m.Verification) { // not required
		return nil
	}

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

	return nil
}

func (m *VerifiedVip) 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 *VerifiedVip) 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 verified vip based on the context it is used
func (m *VerifiedVip) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

	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 *VerifiedVip) contextValidateVerification(ctx context.Context, formats strfmt.Registry) error {

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

	return nil
}

func (m *VerifiedVip) 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 *VerifiedVip) 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 *VerifiedVip) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}

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