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

package types

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

// PostForgotPasswordPayload post forgot password payload
//
// swagger:model postForgotPasswordPayload
type PostForgotPasswordPayload struct {

	// Username to initiate password reset for
	// Example: user@example.com
	// Required: true
	// Max Length: 255
	// Min Length: 1
	// Format: email
	Username *strfmt.Email `json:"username"`
}

// Validate validates this post forgot password payload
func (m *PostForgotPasswordPayload) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *PostForgotPasswordPayload) validateUsername(formats strfmt.Registry) error {

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

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

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

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

	return nil
}

// ContextValidate validates this post forgot password payload based on context it is used
func (m *PostForgotPasswordPayload) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

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

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