R
Roland
Hello,
I have posted the following a while back(2005-03-18), the solution is
at the end:
I have the following problem when trying to use the validator. I have
a field
which should have an entry with the following pattern:
dddd.d+ (4 digits followed by a dot followed by 1 or more digits)
Optionally the field can be empty. Note that strings consisting only
of WHITESPACE are not accepted!
Ok, using the following link I tested two regular expressions that do
what I want:
http://jakarta.apache.org/oro/demo.html
Both of these work:
^(\A\Z)|(\d{4}\.\d+)$
^(^$)|(\d{4}\.\d+)$
Now, if I put either of them in my validation.xml file:
<constant-value>^(^$)|(\d{4}\.\d+)$</constant-value>
<constant-value>^(\A\Z)|(\d{4}\.\d+)$</constant-value>
It doesn't work as expected. It happens that strings consisting only
of whitespace are accepted!
Solution:
Basically what happens is that when the field has only whitespace the
validator considers it as empty and doesn't run it through the
validation routines. That's why whitespace strings are accepted.
I have posted the following a while back(2005-03-18), the solution is
at the end:
I have the following problem when trying to use the validator. I have
a field
which should have an entry with the following pattern:
dddd.d+ (4 digits followed by a dot followed by 1 or more digits)
Optionally the field can be empty. Note that strings consisting only
of WHITESPACE are not accepted!
Ok, using the following link I tested two regular expressions that do
what I want:
http://jakarta.apache.org/oro/demo.html
Both of these work:
^(\A\Z)|(\d{4}\.\d+)$
^(^$)|(\d{4}\.\d+)$
Now, if I put either of them in my validation.xml file:
<constant-value>^(^$)|(\d{4}\.\d+)$</constant-value>
<constant-value>^(\A\Z)|(\d{4}\.\d+)$</constant-value>
It doesn't work as expected. It happens that strings consisting only
of whitespace are accepted!
Solution:
Basically what happens is that when the field has only whitespace the
validator considers it as empty and doesn't run it through the
validation routines. That's why whitespace strings are accepted.