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

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

// PostUIOpenwindowNewmailParamsBody post_ui_openwindow_newmail_new_mail
//
// new_mail object
// swagger:model postUiOpenwindowNewmailParamsBody

type PostUIOpenwindowNewmailParamsBody struct {

	// post_ui_openwindow_newmail_body
	//
	// body string
	// Required: true
	// Max Length: 10000
	Body *string `json:"body"`

	// post_ui_openwindow_newmail_recipients
	//
	// recipients array
	// Required: true
	// Max Items: 50
	// Min Items: 1
	Recipients []int32 `json:"recipients"`

	// post_ui_openwindow_newmail_subject
	//
	// subject string
	// Required: true
	// Max Length: 1000
	Subject *string `json:"subject"`

	// post_ui_openwindow_newmail_to_corp_or_alliance_id
	//
	// to_corp_or_alliance_id integer
	ToCorpOrAllianceID int32 `json:"to_corp_or_alliance_id,omitempty"`

	// post_ui_openwindow_newmail_to_mailing_list_id
	//
	// Corporations, alliances and mailing lists are all types of mailing groups. You may only send to one mailing group, at a time, so you may fill out either this field or the to_corp_or_alliance_ids field
	ToMailingListID int32 `json:"to_mailing_list_id,omitempty"`
}

/* polymorph postUiOpenwindowNewmailParamsBody body false */

/* polymorph postUiOpenwindowNewmailParamsBody recipients false */

/* polymorph postUiOpenwindowNewmailParamsBody subject false */

/* polymorph postUiOpenwindowNewmailParamsBody to_corp_or_alliance_id false */

/* polymorph postUiOpenwindowNewmailParamsBody to_mailing_list_id false */

// Validate validates this post Ui openwindow newmail params body
func (m *PostUIOpenwindowNewmailParamsBody) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

func (m *PostUIOpenwindowNewmailParamsBody) validateBody(formats strfmt.Registry) error {

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

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

	return nil
}

func (m *PostUIOpenwindowNewmailParamsBody) validateRecipients(formats strfmt.Registry) error {

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

	iRecipientsSize := int64(len(m.Recipients))

	if err := validate.MinItems("recipients", "body", iRecipientsSize, 1); err != nil {
		return err
	}

	if err := validate.MaxItems("recipients", "body", iRecipientsSize, 50); err != nil {
		return err
	}

	return nil
}

func (m *PostUIOpenwindowNewmailParamsBody) validateSubject(formats strfmt.Registry) error {

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

	if err := validate.MaxLength("subject", "body", string(*m.Subject), 1000); err != nil {
		return err
	}

	return nil
}

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

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