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

// Permissions permissions
//
// swagger:model Permissions
type Permissions struct {

	// Determines if role has manage (ex. delete) level access
	// Required: true
	Manage *bool `json:"manage"`

	// Determines if role has read level access
	// Required: true
	Read *bool `json:"read"`

	// Determines if role has write level access
	// Required: true
	Write *bool `json:"write"`
}

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

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

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

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

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

func (m *Permissions) validateManage(formats strfmt.Registry) error {

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

	return nil
}

func (m *Permissions) validateRead(formats strfmt.Registry) error {

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

	return nil
}

func (m *Permissions) validateWrite(formats strfmt.Registry) error {

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

	return nil
}

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

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

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