You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: don't allow modifying changeset with atomic conditions
this fixes a bug where by some conditions on changes were not being
honored. This may cause a problem for certiain specific formulations
of changes plus conditions right now, but the current behavior cannot
be kept. We will likely need a way to return after_action hooks that
will be called conditionally if the expression returns true or false
when placed as a calcualtion into the update. Not an easy change
unfortunately.
improvement: add `touching?` option to changing validation
Copy file name to clipboardexpand all lines: lib/ash/resource/validation/changing.ex
+48-20
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,15 @@ defmodule Ash.Resource.Validation.Changing do
15
15
field: [
16
16
type: :atom,
17
17
required: true,
18
-
doc: "The attribute or relationship to check for changes."
18
+
doc:
19
+
"The attribute or relationship to check for changes. Using a relationship does not compare old and new value, returning `true` if the value is being touched)"
20
+
],
21
+
touching?: [
22
+
type: :atom,
23
+
required: false,
24
+
default: false,
25
+
doc:
26
+
"Whether to consider a field as changing if it is just being touched (i.e consider it changed when it is being changed to its current value)"
19
27
]
20
28
]
21
29
end
@@ -35,12 +43,28 @@ defmodule Ash.Resource.Validation.Changing do
0 commit comments