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

// CreateUserOption CreateUserOption create user options
//
// swagger:model CreateUserOption
type CreateUserOption struct {

	// For explicitly setting the user creation timestamp. Useful when users are
	// migrated from other systems. When omitted, the user's creation timestamp
	// will be set to "now".
	// Format: date-time
	Created strfmt.DateTime `json:"created_at,omitempty"`

	// email
	// Required: true
	// Format: email
	Email *strfmt.Email `json:"email"`

	// full name
	FullName string `json:"full_name,omitempty"`

	// login name
	LoginName string `json:"login_name,omitempty"`

	// must change password
	MustChangePassword bool `json:"must_change_password,omitempty"`

	// password
	Password string `json:"password,omitempty"`

	// restricted
	Restricted bool `json:"restricted,omitempty"`

	// send notify
	SendNotify bool `json:"send_notify,omitempty"`

	// source ID
	SourceID int64 `json:"source_id,omitempty"`

	// username
	// Required: true
	Username *string `json:"username"`

	// visibility
	Visibility string `json:"visibility,omitempty"`
}

// Validate validates this create user option
func (m *CreateUserOption) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

func (m *CreateUserOption) validateCreated(formats strfmt.Registry) error {
	if swag.IsZero(m.Created) { // not required
		return nil
	}

	if err := validate.FormatOf("created_at", "body", "date-time", m.Created.String(), formats); err != nil {
		return err
	}

	return nil
}

func (m *CreateUserOption) 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 *CreateUserOption) validateUsername(formats strfmt.Registry) error {

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

	return nil
}

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

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

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