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

package ops

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

// UserUserProfileResp user user profile resp
//
// swagger:model user.UserProfileResp
type UserUserProfileResp struct {

	// email
	Email string `json:"email,omitempty"`

	// name
	Name string `json:"name,omitempty"`

	// region info
	RegionInfo *UserRegionInfo `json:"region_info,omitempty"`

	// roles
	Roles []string `json:"roles"`
}

// Validate validates this user user profile resp
func (m *UserUserProfileResp) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *UserUserProfileResp) validateRegionInfo(formats strfmt.Registry) error {
	if swag.IsZero(m.RegionInfo) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this user user profile resp based on the context it is used
func (m *UserUserProfileResp) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

func (m *UserUserProfileResp) contextValidateRegionInfo(ctx context.Context, formats strfmt.Registry) error {

	if m.RegionInfo != nil {

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

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

	return nil
}

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

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