View Source AshAuthentication.Strategy.Password.PasswordConfirmationValidation (ash_authentication v3.11.10)

Validate that the password and password confirmation match.

This check is only performed when the confirmation_required? DSL option is set to true.

You can use this validation in your own actions where you want to validate that the password and the password confirmation arguments match. If you're not using one of the actions generated by the password strategy then you'll need to manually pass the strategy name in the changeset context. Eg:

Changeset.new(user, %{})
|> Changeset.set_context(%{strategy_name: :password})
|> Changeset.for_update(:change_password, params)
|> Accounts.update()

or by adding it statically in your action definition:

update :change_password do
  change set_context(%{strategy_name: :password})
  change AshAuthentication.Strategy.Password.HashPasswordChange
end

Summary

Functions

Callback implementation for Ash.Resource.Validation.atomic?/1.

Callback implementation for Ash.Resource.Validation.init/1.

Validates that the password and password confirmation fields contain equivalent values - if confirmation is required.

Functions

Callback implementation for Ash.Resource.Validation.atomic?/1.

Callback implementation for Ash.Resource.Validation.init/1.

Link to this function

validate(changeset, options)

View Source
@spec validate(
  Ash.Changeset.t(),
  keyword()
) :: :ok | {:error, String.t() | Exception.t()}

Validates that the password and password confirmation fields contain equivalent values - if confirmation is required.