--- Niall Pemberton <[EMAIL PROTECTED]> wrote:
> Graham
> 
> OK, I decided to look further into your suggestion, but didn't get very
> far
> and I think its because mask doesn't work.

I know it works because I use it in my apps :-).

> 
> I started with a simple expression of [\d,]*  to validate that the input
> only contains numbers or a comma. Whatever I input though validator
> always
> passed it as valid.

ORO's test applet is really helpful when testing regexs.  Try putting ^ at
the front and $ at the end of the pattern.  ORO seems to need these to
work properly unlike Java 1.4 regexs.

David

> 
> Looking into validator it uses Perl5Util.match(pattern, value)
> 
> This utility uses the Perl5Matcher.contains(value, pattern) method which
> only checks that the value contains the pattern - not that matches (it
> says
> so in the Perl5Util documentation).
> 
> Isn't this the wrong thing to do - shouldn't validator be using the
> Perl5Matcher.matches(value, pattern) method. I had a look at commons
> validator test thinking this must be tested for and I must be
> mis-understanding it - but mask seems to be the one thing there are no
> tests
> for - and there don't seem to be any in struts either for
> FieldChecks.validateMask())
> 
> 
> Anyway, am I right - is this a bug, or am I just using it wrongly?
> 
> Niall
> 
> P.S. If I am right, then it implies no one is using mask and I think
> thats
> an argument for my simpler number validation.
> 
> 
> ----- Original Message ----- 
> From: "David Graham" <[EMAIL PROTECTED]>
> To: "Struts Developers List" <[EMAIL PROTECTED]>
> Sent: Thursday, January 15, 2004 10:19 PM
> Subject: Re: Validating Formatted Numbers Patch [Bugzilla 26151]
> 
> 
> > The point of having the mask validation is so we don't have to support
> all
> > variations of patterns.  I'm -1 on adding validators that duplicate
> what
> > can already be done with mask.
> >
> > David
> >
> > --- Niall Pemberton <[EMAIL PROTECTED]> wrote:
> > > Robert,
> > >
> > > I tried to get mask to work (although until today I had no knowledge
> of
> > > regular expressions) using the ORA demonstration applet and  I
> couldn't
> > > get
> > > it to (including your suggestion).
> > >
> > > I'm not saying regular expressions couldn't work (only I don't know
> how
> > > to
> > > make them!), but the pattern's used in DecimalFormat are so much
> more
> > > straight forward and designed for the task. Typically as people are
> > > probably
> > > using a pattern with DecimalFormat to output the data to screen, it
> then
> > > is
> > > much easier and intuitive to specify the same pattern for
> validation.
> > >
> > > I say horses for courses and to me using a number pattern to
> validate
> > > numbers is a better way to do it - hence the enhacement request:
> > >
> > > http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26151
> > >
> > > Thanks
> > >
> > > Niall
> > >
> > > > Robert Leland wrote:
> > > >
> > > > So using mask won't work ? (my syntax below is probably not
> correct)
> > > >
> > > > <field property="amount" depends="required,mask">
> > > >     <arg0 key="sale.amount" />
> > > >     <var>
> > > >           <var-name>mask</var-name>
> > > >           <var-value>\d,\d\d0\:\(\d,\d\d0\)</var-value>
> > > >     </var>
> > > > </field>
> > >
> > > I need to validate numbers which are formatted and have posted a
> patch
> > > to
> > > bugzilla which enhances validator the existing number validations to
> do
> > > this.
> > >
> > > This patch allows an optional "numberPattern" variable to be
> specified
> > > for
> > > the existing byte, short, integer, long, float and double
> validations.
> > > For
> > > Example:
> > >
> > > <field property="amount" depends="required,integer">
> > >     <arg0 key="sale.amount" />
> > >     <var>
> > >           <var-name>numberPattern</var-name>
> > >           <var-value>#,##0:(#,##0)</var-value>
> > >     </var>
> > > </field>
> > >
> > > If the pattern is specified, then java.text.DecimalFormat is used to
> > > parse
> > > the number and check if it is valid (catering for Locale).
> > >
> > > I have also posted a patch to add a new section the Validator User
> Guide
> > > which describes all the standard suppiled validations and shows
> examples
> > > of
> > > usage, including using the new "numberPattern" variable.
> > >
> > > Thanks in advance for any feedback.
> > >
> > > Niall
> > >
> > >
> > >
> > >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
> > http://hotjobs.sweepstakes.yahoo.com/signingbonus
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to