Project

General

Profile

Custom field regular expression not validating on issue update

Added by Tyghe Vallard about 10 years ago

Environment:
  Redmine version                2.4.5.stable
  Ruby version                   2.0.0-p451 (2014-02-24) [x86_64-linux]
  Rails version                  3.2.17
  Environment                    production
  Database adapter               PostgreSQL
SCM:
  Git                            1.7.9.5
  Filesystem                     
Redmine plugins:
  no plugin installed

I have an issue custom field(Long Text) with the following regular expression
^[a-zA-Z0-9-]+$

The expected outcome of this regular expression is that it would ensure that each value in the field(one per line) would only contain lower/upper letters, digits and the dash

If you initially create an issue and set the custom field value to say

a
a b
abc

It will run the regular expression validation and prompt the user with an error about the field being incorrect.
However, if you update an issue and set the custom field to the above value it will save without reporting that the value is incorrect

Not sure if I am missing anything on this, or if this should be reported as a defect.


Replies (4)

RE: Custom field regular expression not validating on issue update - Added by Toshi MARUYAMA almost 10 years ago

^[a-zA-Z0-9-]+$

This is wrong regexp.
I have tried this regexp on Redmine 2.4 and I cannot reproduce.

RE: Custom field regular expression not validating on issue update - Added by Tyghe Vallard almost 10 years ago

Can you elaborate on how it is the wrong regex?

RE: Custom field regular expression not validating on issue update - Added by Toshi MARUYAMA almost 10 years ago

$ irb
1.9.3-p545 :001 > /^[a-zA-Z0-9-]+$/.match("-")
 => #<MatchData "-">
1.9.3-p545 :002 > /^[a-zA-Z0-9]+$/.match("-")
 => nil

RE: Custom field regular expression not validating on issue update - Added by Tyghe Vallard almost 10 years ago

We want any entry that is a-zA-Z0-9 and the dash
We do not want entries that are not that(aka, no spaces)

So the following should fail the regex test:

cannot have space
dash-is-ok

and the following should pass:

this-is-fine
andsoisthis
    (1-4/4)