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

// OSversion OSversion
//
// swagger:model OSversion
type OSversion struct {

	// family of the OS
	// Max Length: 255
	Family string `json:"family,omitempty"`

	// name of the OS
	// Required: true
	// Max Length: 255
	Name *string `json:"name"`

	// version of the OS
	// Required: true
	// Max Length: 255
	Version *string `json:"version"`
}

// Validate validates this o sversion
func (m *OSversion) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

func (m *OSversion) validateFamily(formats strfmt.Registry) error {
	if swag.IsZero(m.Family) { // not required
		return nil
	}

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

	return nil
}

func (m *OSversion) validateName(formats strfmt.Registry) error {

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

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

	return nil
}

func (m *OSversion) validateVersion(formats strfmt.Registry) error {

	if err := validate.Required("version", "body", m.Version); err != nil {
		return err
	}

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

	return nil
}

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

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

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