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

// PostChangePasswordPayload post change password payload
//
// swagger:model postChangePasswordPayload
type PostChangePasswordPayload struct {

	// Current password of user
	// Example: correct horse battery staple
	// Required: true
	// Max Length: 500
	// Min Length: 1
	CurrentPassword *string `json:"currentPassword"`

	// New password to set for user
	// Example: correct horse battery staple
	// Required: true
	// Max Length: 500
	// Min Length: 1
	NewPassword *string `json:"newPassword"`
}

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

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

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

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

func (m *PostChangePasswordPayload) validateCurrentPassword(formats strfmt.Registry) error {

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

	if err := validate.MinLength("currentPassword", "body", *m.CurrentPassword, 1); err != nil {
		return err
	}

	if err := validate.MaxLength("currentPassword", "body", *m.CurrentPassword, 500); err != nil {
		return err
	}

	return nil
}

func (m *PostChangePasswordPayload) validateNewPassword(formats strfmt.Registry) error {

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

	if err := validate.MinLength("newPassword", "body", *m.NewPassword, 1); err != nil {
		return err
	}

	if err := validate.MaxLength("newPassword", "body", *m.NewPassword, 500); err != nil {
		return err
	}

	return nil
}

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

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

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