Skip to content

Commit 879a840

Browse files
committed
docs: document transform_errors option better
1 parent f6bdbff commit 879a840

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/ash_phoenix/form/form.ex

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,23 @@ defmodule AshPhoenix.Form do
213213
"The html id of the form. Defaults to the value of `:as` if provided, otherwise \"form\""
214214
],
215215
transform_errors: [
216-
type: :any,
216+
type: {:or, [{:fun, 2}, {:literal, nil}]},
217217
doc: """
218218
Allows for manual manipulation and transformation of errors.
219219
220220
If possible, try to implement `AshPhoenix.FormData.Error` for the error (if it as a custom one, for example).
221221
If that isn't possible, you can provide this function which will get the changeset and the error, and should
222222
return a list of ash phoenix formatted errors, e.g `[{field :: atom, message :: String.t(), substituations :: Keyword.t()}]`
223+
224+
Example:
225+
226+
AshPhoenix.Form.for_create(..., transform_errors: fn
227+
%{field: :field1} = error ->
228+
%{error | field: :field2}
229+
230+
error ->
231+
error
232+
end
223233
"""
224234
],
225235
prepare_source: [

0 commit comments

Comments
 (0)