Skip to content

Commit

Permalink
chore: draw the rest of the owl on ensure_can_submit
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Feb 6, 2024
1 parent 7d9c876 commit 8ccbed8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/ash_phoenix/form/form.ex
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ defmodule AshPhoenix.Form do
end

@spec can_submit?(t()) :: boolean()
@spec can_submit?(Phoenix.HTML.Form.t(), Keyword.t()) :: Phoenix.HTML.Form.t()
@spec can_submit?(Phoenix.HTML.Form.t()) :: boolean

def can_submit?(%Phoenix.HTML.Form{} = form) do
can_submit?(form.source)
Expand All @@ -650,6 +650,12 @@ defmodule AshPhoenix.Form do
form.source.api.can?(form.source, form.source.context[:private][:actor])
end

@spec ensure_can_submit!(t()) :: t()
@spec ensure_can_submit!(Phoenix.HTML.Form.t()) :: Phoenix.HTML.Form.t()
def ensure_can_submit!(%Phoenix.HTML.Form{} = form) do
%{form | source: ensure_can_submit!(form.source)}
end

def ensure_can_submit!(form) do
unless form.source.api do
raise """
Expand Down

0 comments on commit 8ccbed8

Please sign in to comment.