Problem with STRUTS validator mask regexp

Discussion in 'Java' started by Roland, Mar 18, 2005.

  1. Roland

    Roland Guest

    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
    Roland, Mar 18, 2005
    #1
    1. Advertising

  2. Roland

    Wendy Smoak Guest

    "Roland" <> 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
    Wendy Smoak, Mar 18, 2005
    #2
    1. Advertising

  3. Roland

    Roland Guest

    "Wendy Smoak" <> wrote in message news:<d1fmj1$ejk$>...
    > "Roland" <> 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
    Roland, Mar 21, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roland
    Replies:
    0
    Views:
    1,437
    Roland
    Mar 31, 2005
  2. Replies:
    4
    Views:
    893
    Richter~9.6
    Feb 13, 2007
  3. Marcin Tyman

    Conversion mask in hex to bit mask

    Marcin Tyman, May 6, 2008, in forum: Ruby
    Replies:
    4
    Views:
    796
    Robert Klemme
    May 6, 2008
  4. Joao Silva
    Replies:
    16
    Views:
    354
    7stud --
    Aug 21, 2009
  5. 187
    Replies:
    2
    Views:
    549
    Bart Lateur
    Jul 29, 2004
Loading...

Share This Page