Class: CommandTower::Deserializers::Me::ChangePasswordDeserializer

Inherits:
ApplicationDeserializer show all
Defined in:
app/deserializers/command_tower/deserializers/me/change_password_deserializer.rb

Overview

Transport-only: required fields, camelCase/snake_case, blank detection. LoginStrategy owns password policy, confirmation match, and current-password check.

Defined Under Namespace

Classes: Input

Instance Method Summary collapse

Methods inherited from ApplicationDeserializer

call

Instance Method Details

#call(params) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/deserializers/command_tower/deserializers/me/change_password_deserializer.rb', line 11

def call(params)
  current_password = params[:current_password] || params[:currentPassword]
  password = params[:password]
  password_confirmation = params[:password_confirmation] || params[:passwordConfirmation]

  if blank?(current_password) || blank?(password) || blank?(password_confirmation)
    return failure(errors: { message: "missing_required_fields" })
  end

  unless current_password.is_a?(String) && password.is_a?(String) && password_confirmation.is_a?(String)
    return failure(errors: { message: "invalid_field_types" })
  end

  success(
    Input.new(
      current_password: current_password,
      password: password,
      password_confirmation: password_confirmation
    )
  )
end