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

// AccountMembershipCapabilities account membership capabilities
//
// swagger:model accountMembershipCapabilities
type AccountMembershipCapabilities struct {

	// collaborators
	Collaborators *AccountUsageCapability `json:"collaborators,omitempty"`

	// sites
	Sites *AccountUsageCapability `json:"sites,omitempty"`
}

// Validate validates this account membership capabilities
func (m *AccountMembershipCapabilities) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *AccountMembershipCapabilities) validateCollaborators(formats strfmt.Registry) error {

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

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

	return nil
}

func (m *AccountMembershipCapabilities) validateSites(formats strfmt.Registry) error {

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

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

	return nil
}

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

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