Velocity Reviews - Computer Hardware Reviews

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

Reply
Thread Tools

Problem with STRUTS validator mask regexp

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

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!

So do you have any clues?

Thanks,

Roland
 
Reply With Quote
 
 
 
 
Wendy Smoak
Guest
Posts: n/a
 
      03-18-2005
"Roland" <(E-Mail Removed)> wrote

> 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!


Are you using 'required' in addition to 'mask'?

--
Wendy


 
Reply With Quote
 
 
 
 
Roland
Guest
Posts: n/a
 
      03-21-2005
"Wendy Smoak" <(E-Mail Removed)> wrote in message news:<d1fmj1$ejk$(E-Mail Removed)>...
> "Roland" <(E-Mail Removed)> wrote
>
> > 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!

>
> Are you using 'required' in addition to 'mask'?


No, I'm not using 'required'. The field is not required. There are two
possible entries that are correct:
1. Either the field is empty
2. Or the field has a number in the format dddd.d+

Any other value in the field(including one or more whitespaces) should
lead to an error message.

Roland
 
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
Resolved: Problem with STRUTS validator mask regexp Roland Java 0 03-31-2005 04:57 PM
[networking] Convert subnet mask <=> mask length 187 Perl Misc 2 07-29-2004 10:31 AM



Advertisments