// 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"
	"github.com/go-openapi/validate"
)

// Hit hit
//
// swagger:model Hit
type Hit struct {

	// folder Id
	FolderID int64 `json:"folderId,omitempty"`

	// folder title
	FolderTitle string `json:"folderTitle,omitempty"`

	// folder Uid
	FolderUID string `json:"folderUid,omitempty"`

	// folder Url
	FolderURL string `json:"folderUrl,omitempty"`

	// id
	ID int64 `json:"id,omitempty"`

	// is deleted
	IsDeleted bool `json:"isDeleted,omitempty"`

	// is starred
	IsStarred bool `json:"isStarred,omitempty"`

	// permanently delete date
	// Format: date-time
	PermanentlyDeleteDate strfmt.DateTime `json:"permanentlyDeleteDate,omitempty"`

	// slug
	Slug string `json:"slug,omitempty"`

	// sort meta
	SortMeta int64 `json:"sortMeta,omitempty"`

	// sort meta name
	SortMetaName string `json:"sortMetaName,omitempty"`

	// tags
	Tags []string `json:"tags"`

	// title
	Title string `json:"title,omitempty"`

	// type
	Type HitType `json:"type,omitempty"`

	// uid
	UID string `json:"uid,omitempty"`

	// uri
	URI string `json:"uri,omitempty"`

	// url
	URL string `json:"url,omitempty"`
}

// Validate validates this hit
func (m *Hit) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *Hit) validatePermanentlyDeleteDate(formats strfmt.Registry) error {
	if swag.IsZero(m.PermanentlyDeleteDate) { // not required
		return nil
	}

	if err := validate.FormatOf("permanentlyDeleteDate", "body", "date-time", m.PermanentlyDeleteDate.String(), formats); err != nil {
		return err
	}

	return nil
}

func (m *Hit) validateType(formats strfmt.Registry) error {
	if swag.IsZero(m.Type) { // not required
		return nil
	}

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

	return nil
}

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

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

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

func (m *Hit) contextValidateType(ctx context.Context, formats strfmt.Registry) error {

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

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

	return nil
}

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

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