// Code generated by go-swagger; DO NOT EDIT.

// (c) 2012-2020 by Taxnexus, Inc.
// All rights reserved worldwide.
// Proprietary product; unlicensed use is not allowed

package members_models

import (
	"context"

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

// Track A governed Track root. The schema has no tenant key, so Members derives ownership from the server-owned creator and active Keenan Vision tenant membership.
//
// swagger:model Track
type Track struct {

	// created by ID
	CreatedByID *string `json:"CreatedByID,omitempty"`

	// created date
	CreatedDate *string `json:"CreatedDate,omitempty"`

	// description
	Description *string `json:"Description,omitempty"`

	// ID
	ID string `json:"ID,omitempty"`

	// image alt text
	// Max Length: 250
	ImageAltText *string `json:"ImageAltText,omitempty"`

	// image URL
	// Max Length: 255
	ImageURL *string `json:"ImageURL,omitempty"`

	// last modified by ID
	LastModifiedByID *string `json:"LastModifiedByID,omitempty"`

	// last modified date
	LastModifiedDate *string `json:"LastModifiedDate,omitempty"`

	// logo
	// Max Length: 255
	Logo *string `json:"Logo,omitempty"`

	// name
	// Max Length: 80
	Name string `json:"Name,omitempty"`

	// slug
	// Max Length: 80
	Slug string `json:"Slug,omitempty"`
}

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

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

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

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

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

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

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

func (m *Track) validateImageAltText(formats strfmt.Registry) error {
	if typeutils.IsZero(m.ImageAltText) { // not required
		return nil
	}

	if err := validate.MaxLength("ImageAltText", "body", *m.ImageAltText, 250); err != nil {
		return err
	}

	return nil
}

func (m *Track) validateImageURL(formats strfmt.Registry) error {
	if typeutils.IsZero(m.ImageURL) { // not required
		return nil
	}

	if err := validate.MaxLength("ImageURL", "body", *m.ImageURL, 255); err != nil {
		return err
	}

	return nil
}

func (m *Track) validateLogo(formats strfmt.Registry) error {
	if typeutils.IsZero(m.Logo) { // not required
		return nil
	}

	if err := validate.MaxLength("Logo", "body", *m.Logo, 255); err != nil {
		return err
	}

	return nil
}

func (m *Track) validateName(formats strfmt.Registry) error {
	if typeutils.IsZero(m.Name) { // not required
		return nil
	}

	if err := validate.MaxLength("Name", "body", m.Name, 80); err != nil {
		return err
	}

	return nil
}

func (m *Track) validateSlug(formats strfmt.Registry) error {
	if typeutils.IsZero(m.Slug) { // not required
		return nil
	}

	if err := validate.MaxLength("Slug", "body", m.Slug, 80); err != nil {
		return err
	}

	return nil
}

// ContextValidate validates this track based on context it is used
func (m *Track) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

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

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