Modify ↓
Opened 8 years ago
Closed 7 years ago
#13171 closed defect (worksforme)
Unclear how to use invalid_when validation rule
Reported by: | chuchurocket27 | Owned by: | Ryan J Ollos |
---|---|---|---|
Priority: | normal | Component: | DynamicFieldsPlugin |
Severity: | normal | Keywords: | |
Cc: | Trac Release: | 1.0 |
Description
I have the following snippet in my trac.ini:
trunk_link.invalid_if = ^((?!trunk).)*$ trunk_link.invalid_when = .status .in\s+work (msg:Link to Working Copy must point to an SVN trunk URL)
This validation rule is to make sure the field has the word "trunk" in it before the user can change the status of the ticket. It works fine when the invalid_when
line is commented out (i.e., enforced always) but I want to only enforce this rule when my ticket is set to "in work" (i.e., cannot be routed out of "in work" until that field is valid").
Adding the invalid_when
does not work. I don't think I'm setting this rule correctly - is the preceding .
specific to the CodeReviewPlugin?
Attachments (0)
Note: See
TracTickets for help on using
tickets.
invalid_when
should be a jQuery selector. The following selector worked for me when the ticket has statusaccepted
:So presumably you could use:
However that will prevent *any* ticket changes when the status is in work.
It sounds like you want to prevent only ticket state changes when the status is in work and the
trunk_link
field does not containtrunk
. That's pretty complex for DynamicFieldsPlugin to handle, but you could implement anITicketManipulator
or write a few lines of custom JavaScript (see TracInterfaceCustomization#SiteAppearance).I think it would be very simple to implement in an ITicketManipulator and couldn't be circumvented by disabling JavaScript, as DynamicFieldsPlugin can. If you are interested in pursuing it, please ask on the MailingList and we can talk through how it can be done.