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

package model

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

// CentralRegistrationReq central registration req
//
// swagger:model centralRegistrationReq
type CentralRegistrationReq struct {

	// accept service
	// Required: true
	AcceptService *bool `json:"accept_service"`

	// auth0 token
	// Required: true
	Auth0Token *string `json:"auth0_token"`

	// channel
	Channel bool `json:"channel,omitempty"`

	// company
	// Required: true
	Company *string `json:"company"`

	// connection type
	// Required: true
	ConnectionType *RegistrationReqConnectionType `json:"connection_type"`

	// country
	// Required: true
	Country *string `json:"country"`

	// email
	// Required: true
	Email *string `json:"email"`

	// first name
	// Required: true
	FirstName *string `json:"first_name"`

	// job
	// Required: true
	Job *string `json:"job"`

	// last name
	// Required: true
	LastName *string `json:"last_name"`

	// password
	// Required: true
	Password *string `json:"password"`

	// phone number
	// Required: true
	PhoneNumber *string `json:"phone_number"`

	// recaptcha response
	// Required: true
	RecaptchaResponse *string `json:"recaptcha_response"`

	// return url
	ReturnURL string `json:"return_url,omitempty"`

	// source
	Source *CentralRegistrationSource `json:"source,omitempty"`

	// third party account provider
	// Required: true
	ThirdPartyAccountProvider *string `json:"third_party_account_provider"`

	// third party account token
	ThirdPartyAccountToken string `json:"third_party_account_token,omitempty"`

	// third party free trial
	ThirdPartyFreeTrial bool `json:"third_party_free_trial,omitempty"`
}

// Validate validates this central registration req
func (m *CentralRegistrationReq) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

func (m *CentralRegistrationReq) validateAcceptService(formats strfmt.Registry) error {

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

	return nil
}

func (m *CentralRegistrationReq) validateAuth0Token(formats strfmt.Registry) error {

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

	return nil
}

func (m *CentralRegistrationReq) validateCompany(formats strfmt.Registry) error {

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

	return nil
}

func (m *CentralRegistrationReq) validateConnectionType(formats strfmt.Registry) error {

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

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

	if m.ConnectionType != nil {
		if err := m.ConnectionType.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("connection_type")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("connection_type")
			}
			return err
		}
	}

	return nil
}

func (m *CentralRegistrationReq) validateCountry(formats strfmt.Registry) error {

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

	return nil
}

func (m *CentralRegistrationReq) validateEmail(formats strfmt.Registry) error {

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

	return nil
}

func (m *CentralRegistrationReq) validateFirstName(formats strfmt.Registry) error {

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

	return nil
}

func (m *CentralRegistrationReq) validateJob(formats strfmt.Registry) error {

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

	return nil
}

func (m *CentralRegistrationReq) validateLastName(formats strfmt.Registry) error {

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

	return nil
}

func (m *CentralRegistrationReq) validatePassword(formats strfmt.Registry) error {

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

	return nil
}

func (m *CentralRegistrationReq) validatePhoneNumber(formats strfmt.Registry) error {

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

	return nil
}

func (m *CentralRegistrationReq) validateRecaptchaResponse(formats strfmt.Registry) error {

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

	return nil
}

func (m *CentralRegistrationReq) validateSource(formats strfmt.Registry) error {
	if swag.IsZero(m.Source) { // not required
		return nil
	}

	if m.Source != nil {
		if err := m.Source.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("source")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("source")
			}
			return err
		}
	}

	return nil
}

func (m *CentralRegistrationReq) validateThirdPartyAccountProvider(formats strfmt.Registry) error {

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

	return nil
}

// ContextValidate validate this central registration req based on the context it is used
func (m *CentralRegistrationReq) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *CentralRegistrationReq) contextValidateConnectionType(ctx context.Context, formats strfmt.Registry) error {

	if m.ConnectionType != nil {

		if err := m.ConnectionType.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("connection_type")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("connection_type")
			}
			return err
		}
	}

	return nil
}

func (m *CentralRegistrationReq) contextValidateSource(ctx context.Context, formats strfmt.Registry) error {

	if m.Source != nil {

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

		if err := m.Source.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("source")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("source")
			}
			return err
		}
	}

	return nil
}

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

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