Pre-transition value of fields for validators

Issue #939 new
Tiago Fernandes
created an issue

In a validator, it would be very useful to access the value a field had at the beginning of the transition.

Use case: I have a transition used to modify fixed versions. I want to restrict users from adding a particular fixed version, but if that fixed version is already in there, then the validator should let it be.

Example of use case in action: Only users in the group "special" can add the fixed version X. scenario a| a ticket currently has fixed version Y. If a non-special user adds fixed version X to it, the validator should block the transition. scenario b| a ticket currently has fixed version X. If a non-special user adds fixed version Y to it, the validator should permit the transition.

To implement the validator, I thought the following would work: (("Y" in toStringList(%{Fixed versions})) and not ("Y" in toStringList(previousValue(%{Fixed versions})))) implies isInRole(%{Current user}, "special")

The implementation above assumes that the %{Fixed versions} return the new value being set by the user during the transition (true assumption), and that previousValue(%{Fixed versions}) return the value at the beginning of the transition (false assumption). Previous value is actually returning the value the field had before the pre-transition value. There is no way to get the value that a field had at the beginning of the transition.

To correctly implement this use case, there would need to be a way to check both the intended post-transition value (which already exists) and a way to check the pre-transition value (which is the current value of the field until the transition is successfully finalized - this doesn't exist)

Comments (1)

  1. Log in to comment