aspose file tools*
The moose likes Struts and the fly likes Struts validator-rules.xml regex problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts validator-rules.xml regex problem" Watch "Struts validator-rules.xml regex problem" New topic
Author

Struts validator-rules.xml regex problem

Amieya Prabhaker
Ranch Hand

Joined: Apr 23, 2006
Posts: 45
Hello,
I have a rule for bank accounts set as ^[0-9]{6,8}$ in validator-rules.xml

That is to say the account number is 6 to 8 digits long and takes in numbers 0-9. The full text is as under:

<constant><constant-name>accountno</constant-name> <constant-value>^[0-9]{6,8}$</constant-value></constant>

I want to add in an additional constraint that the account number should be non-zero; so someone should not try entering in 000000, 0000000 or 00000000 since the current regex above will allow these to be entered.

Can you please suggest the change required to the regex pattern to achieve this.
Thanks.
P.S: Corresponding validation.xml and other files are set up correctly.
Amieya Prabhaker
Ranch Hand

Joined: Apr 23, 2006
Posts: 45
Any struts/ regular expressions gurus out here.

I have tried some sort of -(000000) kind of pattern; i.e. above pattern minus the all zeros case, but it does not work.

Thanks.
Amieya Prabhaker
Ranch Hand

Joined: Apr 23, 2006
Posts: 45
I wonder if this problem can be fixed using the intRange in validation.xml rather than the regex in validator-rules.xml

Greatly appreciate any struts gurus to help me out here!
Dom Lassy
Ranch Hand

Joined: May 05, 2006
Posts: 181
Can't you make a validator rule for a positive number and apply that rule as well as your regex mask?
Amieya Prabhaker
Ranch Hand

Joined: Apr 23, 2006
Posts: 45
Can you please give an example how I can create a validator rule.

Greatly appreciate the input as I'm still learning the nuts and bolts of this. Thanks.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Struts validator-rules.xml regex problem