Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Resolved: Problem with STRUTS validator mask regexp

Reply
Thread Tools

Resolved: Problem with STRUTS validator mask regexp

 
 
Roland
Guest
Posts: n/a
 
      03-31-2005
Hello,

I have posted the following a while back(2005-03-1, 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[regexp] How to convert string "/regexp/i" to /regexp/i - ? Joao Silva Ruby 16 08-21-2009 05:52 PM
Conversion mask in hex to bit mask Marcin Tyman Ruby 4 05-06-2008 08:15 PM
Struts Validator - creditCard validator smrimell@gmail.com Java 4 02-13-2007 08:32 PM
Problem with STRUTS validator mask regexp Roland Java 2 03-21-2005 08:37 PM
[networking] Convert subnet mask <=> mask length 187 Perl Misc 2 07-29-2004 10:31 AM



Advertisments