-
-
Notifications
You must be signed in to change notification settings - Fork 91
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Code of Conduct
- I agree to follow this project's Code of Conduct
AI Policy
- I agree to follow this project's AI Policy, or I agree that AI was not used while creating this issue.
Versions
ash: 3.5.37
ash_phoenix: 2.3.14
inertia: 2.5.1
elixir: 1.18.4
erlang/otp: 28
Operating system
macOS Sequoia
Current Behavior
Calling assign_errors generates an exception when the validation rule in an attribute uses present and/or the absent builtin functions.
Reproduction
defmodule Demo.Recipe do
use Ash.Resource,
domain: Demo
attributes do
uuid_primary_key :id
attribute :title, :string
attribute :cook_time_minutes, :integer
end
validations do
validate present([:title])
end
actions do
create :create do
accept [:title, :cook_time_minutes]
end
end
end
defmodule Demo do
use Ash.Domain
resources do
resource Demo.Recipe
end
end
Create a changeset:
changeset =
Demo.Recipe
|> Ash.Changeset.for_create(:create, %{
"cook_time_minutes" => "15"
})
The changeset contains the expected error:
#Ash.Changeset<
domain: Demo,
action_type: :create,
action: :create,
attributes: %{cook_time_minutes: 15},
relationships: %{},
errors: [
%Ash.Error.Changes.InvalidAttribute{
field: :title,
message: "must be present",
private_vars: nil,
value: nil,
has_value?: true,
splode: nil,
bread_crumbs: [],
vars: [fields: [:title], keys: "title", attributes: [:title], exactly: 1],
path: [],
stacktrace: #Splode.Stacktrace<>,
class: :invalid
}
],
data: %Demo.Recipe{
id: nil,
title: nil,
cook_time_minutes: nil,
__meta__: #Ecto.Schema.Metadata<:built, "">
},
valid?: false
>
Attempting to call the Inertia.Errors implementation:
AshPhoenix.Inertia.Error.to_errors(changeset)
Raises the following error:
** (ArgumentError) cannot convert the given list to a string.
To be converted to a string, a list must either be empty or only
contain the following elements:
* strings
* integers representing Unicode code points
* a list containing one of these three elements
Please check the given list or call inspect/1 to get the list representation, got:
[:title]
Expected Behavior
No exceptions should be raised.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working