Skip to content

Commit

Permalink
Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
mbashia committed Dec 2, 2024
1 parent be0be2e commit 367340a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 6 additions & 0 deletions lib/mpesa/stk_form.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
defmodule Mpesa.StkForm do
@moduledoc """
A module for handling and validating STK push form data in the Mpesa integration.
It validates the phone number format and ensures that the amount is greater than zero.
"""

import Ecto.Changeset

@types %{
Expand Down
4 changes: 0 additions & 4 deletions lib/mpesa_web/live/stk_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,16 @@ defmodule MpesaWeb.Stklive.Index do
socket
) do
# Use a plain map as data
IO.inspect(params, label: "Inspecting params")
data = %{}

# Build the changeset
changeset = StkForm.changeset(data, %{:Phone_number => phone_number, :amount => amount})
IO.inspect(changeset, label: "Inspecting changeset")

{:noreply, assign(socket, form: to_form(changeset, action: :validate, as: "stk_form"))}
end
end

## test- if phone number is valid
## test- if amount is greater than 0
##
## test- if phone number is invalid

## validate phone number

0 comments on commit 367340a

Please sign in to comment.