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

// ThingWithEnumHashKey thing with enum hash key
//
// swagger:model ThingWithEnumHashKey
type ThingWithEnumHashKey struct {

	// branch
	Branch Branch `json:"branch,omitempty"`

	// date
	// Format: date-time
	Date strfmt.DateTime `json:"date,omitempty"`

	// date2
	// Format: date-time
	Date2 strfmt.DateTime `json:"date2,omitempty"`
}

// Validate validates this thing with enum hash key
func (m *ThingWithEnumHashKey) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

func (m *ThingWithEnumHashKey) validateBranch(formats strfmt.Registry) error {

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

	if err := m.Branch.Validate(formats); err != nil {
		if ve, ok := err.(*errors.Validation); ok {
			return ve.ValidateName("branch")
		}
		return err
	}

	return nil
}

func (m *ThingWithEnumHashKey) validateDate(formats strfmt.Registry) error {

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

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

	return nil
}

func (m *ThingWithEnumHashKey) validateDate2(formats strfmt.Registry) error {

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

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

	return nil
}

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

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