diff --git a/lib/ash/actions/managed_relationships.ex b/lib/ash/actions/managed_relationships.ex index be74b82d..37f6411e 100644 --- a/lib/ash/actions/managed_relationships.ex +++ b/lib/ash/actions/managed_relationships.ex @@ -443,7 +443,7 @@ defmodule Ash.Actions.ManagedRelationships do |> Ash.Changeset.add_error( InvalidRelationship.exception( relationship: relationship.name, - message: "Changes would create a new related record" + message: "changes would create a new related record" ) ) |> Ash.Changeset.put_context(:private, %{ @@ -1082,7 +1082,7 @@ defmodule Ash.Actions.ManagedRelationships do {:error, InvalidRelationship.exception( relationship: relationship.name, - message: "Changes would create a new related record" + message: "changes would create a new related record" )} end @@ -1236,7 +1236,7 @@ defmodule Ash.Actions.ManagedRelationships do {:error, InvalidRelationship.exception( relationship: relationship.name, - message: "Changes would update a record" + message: "changes would update a record" )} :ignore -> @@ -1621,7 +1621,7 @@ defmodule Ash.Actions.ManagedRelationships do {:error, InvalidRelationship.exception( relationship: relationship.name, - message: "Changes would destroy a record" + message: "changes would destroy a record" )}} {:unrelate, action_name} -> diff --git a/lib/ash/actions/read.ex b/lib/ash/actions/read.ex index 7dd39c22..93f7c16b 100644 --- a/lib/ash/actions/read.ex +++ b/lib/ash/actions/read.ex @@ -496,7 +496,7 @@ defmodule Ash.Actions.Read do %Ash.Query.Ref{attribute: %Ash.Resource.Calculation{}} = ref -> raise Ash.Error.Framework.AssumptionFailed, - message: "Unhandled calculation in filter statement #{inspect(ref)}" + message: "unhandled calculation in filter statement #{inspect(ref)}" %Ash.Query.Ref{attribute: %Ash.Query.Calculation{} = calc} = ref -> %{ @@ -1738,7 +1738,7 @@ defmodule Ash.Actions.Read do ) else raise Ash.Error.Framework.AssumptionFailed, - message: "Only calculation & relationship deps should have input" + message: "only calculation & relationship deps should have input" end %Ash.Query.Calculation{} = calculation -> @@ -1785,7 +1785,7 @@ defmodule Ash.Actions.Read do true -> raise Ash.Error.Framework.AssumptionFailed, message: - "Only attribute & aggregate deps should remain at this point. Got #{inspect(other)} on #{inspect(query.resource)}" + "only attribute & aggregate deps should remain at this point, got #{inspect(other)} on #{inspect(query.resource)}" end end) end diff --git a/lib/ash/changeset/changeset.ex b/lib/ash/changeset/changeset.ex index 9a922257..d371bafa 100644 --- a/lib/ash/changeset/changeset.ex +++ b/lib/ash/changeset/changeset.ex @@ -2625,7 +2625,7 @@ defmodule Ash.Changeset do error = InvalidRelationship.exception( relationship: relationship.name, - message: "Relationship is not editable" + message: "relationship is not editable" ) add_error(changeset, error) @@ -2634,7 +2634,7 @@ defmodule Ash.Changeset do error = InvalidRelationship.exception( relationship: relationship.name, - message: "Cannot manage a manual relationship" + message: "cannot manage a manual relationship" ) add_error(changeset, error) @@ -2643,7 +2643,7 @@ defmodule Ash.Changeset do error = InvalidRelationship.exception( relationship: relationship.name, - message: "Cannot manage a #{type} relationship with a list of records" + message: "cannot manage a #{type} relationship with a list of records" ) add_error(changeset, error) @@ -2707,7 +2707,7 @@ defmodule Ash.Changeset do changeset, InvalidRelationship.exception( relationship: relationship.name, - message: "Cannot provide structs that don't match the destination" + message: "cannot provide structs that don't match the destination" ) ) else diff --git a/lib/ash/error/changes/unknown_error.ex b/lib/ash/error/changes/unknown_error.ex deleted file mode 100644 index 340eb5be..00000000 --- a/lib/ash/error/changes/unknown_error.ex +++ /dev/null @@ -1,16 +0,0 @@ -defmodule Ash.Error.Changes.UnknownError do - @moduledoc "Used when a change fails for an unknown reason" - use Ash.Error.Exception - - def_ash_error([:field, :error], class: :invalid) - - defimpl Ash.ErrorKind do - def id(_), do: Ash.UUID.generate() - - def code(_), do: "unknown_change_error" - - def message(%{field: field, error: error}) do - "Unknown error for change on field #{field}: #{inspect(error)}" - end - end -end diff --git a/lib/ash/error/forbidden/policy.ex b/lib/ash/error/forbidden/policy.ex index 3e1d5b4f..c07a7c1d 100644 --- a/lib/ash/error/forbidden/policy.ex +++ b/lib/ash/error/forbidden/policy.ex @@ -407,6 +407,6 @@ defmodule Ash.Error.Forbidden.Policy do end end - def code(_), do: "forbidden" + def code(_), do: "forbidden_by_policy" end end diff --git a/lib/ash/filter/filter.ex b/lib/ash/filter/filter.ex index abb53993..d7fe5f38 100644 --- a/lib/ash/filter/filter.ex +++ b/lib/ash/filter/filter.ex @@ -2379,7 +2379,7 @@ defmodule Ash.Filter do InvalidFilterValue.exception( value: inspect(nested_statement), message: - "A single value must be castable to the primary key of the resource: #{inspect(context.resource)}" + "a single value must be castable to the primary key of the resource: #{inspect(context.resource)}" )} end end @@ -2666,7 +2666,7 @@ defmodule Ash.Filter do Ash.Error.Query.InvalidExpression.exception( expression: expr, message: - "Cannot access multiple resources for a data layer that can't be joined from within a single expression" + "cannot access multiple resources for a data layer that can't be joined from within a single expression" )} end @@ -2674,7 +2674,7 @@ defmodule Ash.Filter do {:error, Ash.Error.Query.InvalidExpression.exception( expression: expr, - message: "Cannot access multiple data layers within a single expression" + message: "cannot access multiple data layers within a single expression" )} end end diff --git a/lib/ash/resource/change/relate_actor.ex b/lib/ash/resource/change/relate_actor.ex index bfaaf4b8..61aacd6d 100644 --- a/lib/ash/resource/change/relate_actor.ex +++ b/lib/ash/resource/change/relate_actor.ex @@ -22,7 +22,7 @@ defmodule Ash.Resource.Change.RelateActor do changeset, InvalidRelationship.exception( relationship: opts[:relationship], - message: "Could not relate to actor, as no actor was found (and :allow_nil? is false)" + message: "could not relate to actor, as no actor was found (and :allow_nil? is false)" ) ) end diff --git a/lib/ash/resource/validation/builtins.ex b/lib/ash/resource/validation/builtins.ex index 378224aa..f327836a 100644 --- a/lib/ash/resource/validation/builtins.ex +++ b/lib/ash/resource/validation/builtins.ex @@ -179,7 +179,7 @@ defmodule Ash.Resource.Validation.Builtins do validate numericality(:age, greater_than_or_equal_to: 18), where: [attribute_equals(:show_adult_content, true)], - message: "Must be over %{greater_than_or_equal_to} to enable adult content." + message: "must be over %{greater_than_or_equal_to} to enable adult content." validate numericality(:points, greater_than: 0, less_than_or_equal_to: 100) """ diff --git a/lib/ash/resource/validation/confirm.ex b/lib/ash/resource/validation/confirm.ex index 1d5597fe..8f305414 100644 --- a/lib/ash/resource/validation/confirm.ex +++ b/lib/ash/resource/validation/confirm.ex @@ -42,7 +42,7 @@ defmodule Ash.Resource.Validation.Confirm do InvalidAttribute.exception( field: opts[:confirmation], value: confirmation_value, - message: "Confirmation did not match value" + message: "confirmation did not match value" )} end end diff --git a/lib/ash/resource/validation/string_length.ex b/lib/ash/resource/validation/string_length.ex index 21f49b8b..c1be49f5 100644 --- a/lib/ash/resource/validation/string_length.ex +++ b/lib/ash/resource/validation/string_length.ex @@ -37,8 +37,7 @@ defmodule Ash.Resource.Validation.StringLength do InvalidAttribute.exception( value: value, field: opts[:attribute], - message: "%{field} could not be parsed", - vars: [field: opts[:attribute]] + message: "could not be parsed" )} end @@ -60,8 +59,8 @@ defmodule Ash.Resource.Validation.StringLength do InvalidAttribute.exception( value: value, field: opts[:attribute], - message: "%{field} must have length of exactly %{exact}", - vars: [field: opts[:attribute], exact: exact] + message: "must have length of exactly %{exact}", + vars: [exact: exact] )} end end @@ -76,8 +75,8 @@ defmodule Ash.Resource.Validation.StringLength do InvalidAttribute.exception( value: value, field: opts[:attribute], - message: "%{field} must have length of between %{min} and %{max}", - vars: [field: opts[:attribute], min: min, max: max] + message: "must have length of between %{min} and %{max}", + vars: [min: min, max: max] )} end end @@ -90,8 +89,8 @@ defmodule Ash.Resource.Validation.StringLength do InvalidAttribute.exception( value: value, field: opts[:attribute], - message: "%{field} must have length of at least %{min}", - vars: [field: opts[:attribute], min: min] + message: "must have length of at least %{min}", + vars: [min: min] )} end end @@ -104,8 +103,8 @@ defmodule Ash.Resource.Validation.StringLength do InvalidAttribute.exception( value: value, field: opts[:attribute], - message: "%{field} must have length of no more than %{max}", - vars: [field: opts[:attribute], max: max] + message: "must have length of no more than %{max}", + vars: [max: max] )} end end diff --git a/test/changeset/changeset_test.exs b/test/changeset/changeset_test.exs index e4a5145b..5435db2e 100644 --- a/test/changeset/changeset_test.exs +++ b/test/changeset/changeset_test.exs @@ -519,7 +519,7 @@ defmodule Ash.Test.Changeset.ChangesetTest do post2 = %{title: "title"} assert_raise Ash.Error.Invalid, - ~r/Invalid value provided for posts: Changes would create a new related record/, + ~r/Invalid value provided for posts: changes would create a new related record/, fn -> Author |> Changeset.new() @@ -786,7 +786,7 @@ defmodule Ash.Test.Changeset.ChangesetTest do ) assert [%Ash.Error.Changes.InvalidRelationship{} = relation_error] = changeset.errors - assert relation_error.message =~ "Cannot provide structs that don't match the destination" + assert relation_error.message =~ "cannot provide structs that don't match the destination" end test "it returns error if relationship does not exists" do @@ -872,7 +872,7 @@ defmodule Ash.Test.Changeset.ChangesetTest do end test "arguments can be used in invalid changes" do - assert_raise Ash.Error.Invalid, ~r/Confirmation did not match value/, fn -> + assert_raise Ash.Error.Invalid, ~r/confirmation did not match value/, fn -> Category |> Changeset.new(%{"name" => "foo"}) |> Changeset.set_argument(:confirm_name, "bar") @@ -904,7 +904,7 @@ defmodule Ash.Test.Changeset.ChangesetTest do %Ash.Error.Changes.InvalidAttribute{ class: :invalid, field: :confirm_name, - message: "Confirmation did not match value", + message: "confirmation did not match value", path: [] } ] = diff --git a/test/resource/validation/string_length_test.exs b/test/resource/validation/string_length_test.exs index a5c8078c..1be0be2f 100644 --- a/test/resource/validation/string_length_test.exs +++ b/test/resource/validation/string_length_test.exs @@ -25,7 +25,7 @@ defmodule Ash.Test.Resource.Validation.StringLengthTest do {:ok, opts} = StringLength.init(attribute: :body, min: 3) changeset = Ash.Changeset.new(Post, %{body: "no"}) - assert_error(changeset, opts, "body must have length of at least 3") + assert_error(changeset, opts, "must have length of at least 3") end end @@ -41,7 +41,7 @@ defmodule Ash.Test.Resource.Validation.StringLengthTest do {:ok, opts} = StringLength.init(attribute: :body, max: 3) changeset = Ash.Changeset.new(Post, %{body: "invalid"}) - assert_error(changeset, opts, "body must have length of no more than 3") + assert_error(changeset, opts, "must have length of no more than 3") end end @@ -57,10 +57,10 @@ defmodule Ash.Test.Resource.Validation.StringLengthTest do {:ok, opts} = StringLength.init(attribute: :body, exact: 3) changeset = Ash.Changeset.new(Post, %{body: "no"}) - assert_error(changeset, opts, "body must have length of exactly 3") + assert_error(changeset, opts, "must have length of exactly 3") changeset = Ash.Changeset.new(Post, %{body: "invalid"}) - assert_error(changeset, opts, "body must have length of exactly 3") + assert_error(changeset, opts, "must have length of exactly 3") end end @@ -76,10 +76,10 @@ defmodule Ash.Test.Resource.Validation.StringLengthTest do {:ok, opts} = StringLength.init(attribute: :body, min: 2, max: 4) changeset = Ash.Changeset.new(Post, %{body: "n"}) - assert_error(changeset, opts, "body must have length of between 2 and 4") + assert_error(changeset, opts, "must have length of between 2 and 4") changeset = Ash.Changeset.new(Post, %{body: "invalid"}) - assert_error(changeset, opts, "body must have length of between 2 and 4") + assert_error(changeset, opts, "must have length of between 2 and 4") end end