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

// (c) 2012-2020 by Taxnexus, Inc.
// All rights reserved worldwide.
// Proprietary product; unlicensed use is not allowed

package members_models

import (
	"context"

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

// OnboardRequest Self-service onboarding request. The plaintext password is hashed server-side with the members pepper; it is never stored or logged in plaintext.
//
// swagger:model OnboardRequest
type OnboardRequest struct {

	// Company name
	CompanyName string `json:"companyName,omitempty"`

	// Login email (stored lowercased)
	// Required: true
	// Format: email
	Email *strfmt.Email `json:"email"`

	// First name
	FirstName string `json:"firstName,omitempty"`

	// Last name
	LastName string `json:"lastName,omitempty"`

	// Plaintext password; Members enforces 12-64 valid UTF-8 bytes before hashing.
	// Required: true
	// Format: password
	Password *strfmt.Password `json:"password"`
}

// Validate validates this onboard request
func (m *OnboardRequest) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

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

	return nil
}

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

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

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

	return nil
}

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

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

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