You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Niall Pemberton <ni...@blueyonder.co.uk> on 2004/01/15 16:14:08 UTC

Validating Formatted Numbers Patch [Bugzilla 26151]

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.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26151

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





Re: OT RE: Validating Formatted Numbers Patch [Bugzilla 26151]

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
Heres to lots more grief in the future hey lol!

----- Original Message ----- 
From: "Richard Hightower" <rh...@arc-mind.com>
To: "Struts Developers List" <st...@jakarta.apache.org>
Sent: Friday, January 16, 2004 10:42 PM
Subject: OT RE: Validating Formatted Numbers Patch [Bugzilla 26151]


> Grief imparts the most knowledge. What would joy mean if we did not have
> agony?!
>
> I've learned a few things from you grief.
> You contributed a patch, and found another bug with the mask rule.
>
> Your grief has benefitted the group.
>
> Thanks for sharing your grief.
>
>
> Rick Hightower
> Developer
>
> Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
> Struts/J2EE consulting --
> http://www.arc-mind.com/consulting.htm#StrutsMentoring
>
>
>
> -----Original Message-----
> From: Niall Pemberton [mailto:niall.pemberton@blueyonder.co.uk]
> Sent: Friday, January 16, 2004 11:23 AM
> To: Struts Developers List
> Subject: Re: Validating Formatted Numbers Patch [Bugzilla 26151]
>
>
> Caused me some grief....plus a complete lack knowledge of RegExp until
> yesterday. Anyway, thanks to everyone for the help and input - I know more
> today than I did yesterday.
>
> I've put a enhancement request into Bugzilla with patch on Commons to
change
> this - fingers crossed it will be approved.
>
> Niall
>
> ----- Original Message -----
> From: "Richard Hightower" <rh...@arc-mind.com>
> To: "Struts Developers List" <st...@jakarta.apache.org>
> Sent: Friday, January 16, 2004 6:00 PM
> Subject: RE: Validating Formatted Numbers Patch [Bugzilla 26151]
>
>
> > Niall,
> >
> > Good catch!
> >
> > I was wondering why I had to always specify ^ and $.
> >
> > I wrote a few of my own validator rules (e.g., zip code and phone
number),
> > and I used regex from java.
> > I used the match function. This explains some mysteries in my head.
> >
> >
> >
> >
> > -----Original Message-----
> > From: Niall Pemberton [mailto:niall.pemberton@blueyonder.co.uk]
> > Sent: Friday, January 16, 2004 8:30 AM
> > To: Struts Developers List
> > Subject: Re: Validating Formatted Numbers Patch [Bugzilla 26151]
> >
> >
> > I already tried it, and it is backward compatible. The thing about
> Perl5Util
> > is it provides a convinience method
> > of match(value, pattern) which creates a Perl5Compiler, builds a cache
of
> > compiled patterns and calls the Perl5Matcher.contains()
> > method. There isn't an equivalent convinience method that calls the
> > Perl5Matcher.matches() method.
> >
> > Replacing:
> > boolean match = Perl5Util.match(value, pattern)
> >
> > requires:
> >
> > Perl5Compiler compiler = new Perl5Compiler();
> > Pattern compiledPattern = compiler.compile(pattern);
> > Perl5Matcher matcher   = new Perl5Matcher();
> > boolean match = matcher.matches(value, compiledPattern);
> >
> > But then, it would be less efficient as the pattern is being compiled
> every
> > time. It would be
> > straight forward to do the equivalent of Perl5Util and create a cache.
> >
> > I might have a look at this later and submit a patch to Commons.
> >
> > Niall
> >
> > ----- Original Message -----
> > >  "David Graham" <gr...@yahoo.com> wrote:
> > >
> > > --- Niall Pemberton <ni...@blueyonder.co.uk> wrote:
> > > > Hey thanks for your help - what you suggested worked (i.e. using
> > > > "^[\d,]*$") - I was using the ORO demo, but if you don't put the
right
> > > > stuff
> > > > in....:-)
> > > >
> > > > OK, I'm picking up regex slowly - so this works because ^ is for the
> > > > beginning of a line and % is for the end of a line.
> > >
> > > I think you meant $ instead of % but yes that's correct.
> > >
> > > >
> > > > Apologies for the "doesn't work" slander then - but wouldn't it be
> > > > better to
> > > > use Perl5Matcher.matches(value, pattern) and then there would be no
> need
> > > > to
> > > > specify the ^ and $ characters at the start and end - simpler and
less
> > > > confusing?
> > > >
> > > > This could be done and would be backward compatible.
> > >
> > > I really haven't looked at the differences between matches() and
> > > contains() so I don't know if it's backwards compatible.  You could
try
> > > changing it and let us know what happens.
> > >
> > > David
> > >
> > > >
> > > > Niall
> > > >
> > > >
> > > >
> > > > ----- Original Message -----
> > > > From: "David Graham" <gr...@yahoo.com>
> > > > To: "Struts Developers List" <st...@jakarta.apache.org>
> > > > Sent: Friday, January 16, 2004 1:39 PM
> > > > Subject: Re: Validating Formatted Numbers Patch [Bugzilla 26151]
> > > >
> > > >
> > > > >
> > > > > --- Niall Pemberton <ni...@blueyonder.co.uk> 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" <gr...@yahoo.com>
> > > > > > To: "Struts Developers List" <st...@jakarta.apache.org>
> > > > > > 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 <ni...@blueyonder.co.uk> 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:
> > > > struts-dev-unsubscribe@jakarta.apache.org
> > > > > > > > For additional commands, e-mail:
> > > > struts-dev-help@jakarta.apache.org
> > > > > > > >
> > > > > > >
> > > >
> > > === message truncated ===
> > >
> > >
> > > __________________________________
> > > Do you Yahoo!?
> > > Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
> > > http://hotjobs.sweepstakes.yahoo.com/signingbonus
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> > >
> > >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


OT RE: Validating Formatted Numbers Patch [Bugzilla 26151]

Posted by Richard Hightower <rh...@arc-mind.com>.
Grief imparts the most knowledge. What would joy mean if we did not have
agony?!

I've learned a few things from you grief.
You contributed a patch, and found another bug with the mask rule.

Your grief has benefitted the group.

Thanks for sharing your grief.


Rick Hightower
Developer

Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
Struts/J2EE consulting --
http://www.arc-mind.com/consulting.htm#StrutsMentoring



-----Original Message-----
From: Niall Pemberton [mailto:niall.pemberton@blueyonder.co.uk]
Sent: Friday, January 16, 2004 11:23 AM
To: Struts Developers List
Subject: Re: Validating Formatted Numbers Patch [Bugzilla 26151]


Caused me some grief....plus a complete lack knowledge of RegExp until
yesterday. Anyway, thanks to everyone for the help and input - I know more
today than I did yesterday.

I've put a enhancement request into Bugzilla with patch on Commons to change
this - fingers crossed it will be approved.

Niall

----- Original Message -----
From: "Richard Hightower" <rh...@arc-mind.com>
To: "Struts Developers List" <st...@jakarta.apache.org>
Sent: Friday, January 16, 2004 6:00 PM
Subject: RE: Validating Formatted Numbers Patch [Bugzilla 26151]


> Niall,
>
> Good catch!
>
> I was wondering why I had to always specify ^ and $.
>
> I wrote a few of my own validator rules (e.g., zip code and phone number),
> and I used regex from java.
> I used the match function. This explains some mysteries in my head.
>
>
>
>
> -----Original Message-----
> From: Niall Pemberton [mailto:niall.pemberton@blueyonder.co.uk]
> Sent: Friday, January 16, 2004 8:30 AM
> To: Struts Developers List
> Subject: Re: Validating Formatted Numbers Patch [Bugzilla 26151]
>
>
> I already tried it, and it is backward compatible. The thing about
Perl5Util
> is it provides a convinience method
> of match(value, pattern) which creates a Perl5Compiler, builds a cache of
> compiled patterns and calls the Perl5Matcher.contains()
> method. There isn't an equivalent convinience method that calls the
> Perl5Matcher.matches() method.
>
> Replacing:
> boolean match = Perl5Util.match(value, pattern)
>
> requires:
>
> Perl5Compiler compiler = new Perl5Compiler();
> Pattern compiledPattern = compiler.compile(pattern);
> Perl5Matcher matcher   = new Perl5Matcher();
> boolean match = matcher.matches(value, compiledPattern);
>
> But then, it would be less efficient as the pattern is being compiled
every
> time. It would be
> straight forward to do the equivalent of Perl5Util and create a cache.
>
> I might have a look at this later and submit a patch to Commons.
>
> Niall
>
> ----- Original Message -----
> >  "David Graham" <gr...@yahoo.com> wrote:
> >
> > --- Niall Pemberton <ni...@blueyonder.co.uk> wrote:
> > > Hey thanks for your help - what you suggested worked (i.e. using
> > > "^[\d,]*$") - I was using the ORO demo, but if you don't put the right
> > > stuff
> > > in....:-)
> > >
> > > OK, I'm picking up regex slowly - so this works because ^ is for the
> > > beginning of a line and % is for the end of a line.
> >
> > I think you meant $ instead of % but yes that's correct.
> >
> > >
> > > Apologies for the "doesn't work" slander then - but wouldn't it be
> > > better to
> > > use Perl5Matcher.matches(value, pattern) and then there would be no
need
> > > to
> > > specify the ^ and $ characters at the start and end - simpler and less
> > > confusing?
> > >
> > > This could be done and would be backward compatible.
> >
> > I really haven't looked at the differences between matches() and
> > contains() so I don't know if it's backwards compatible.  You could try
> > changing it and let us know what happens.
> >
> > David
> >
> > >
> > > Niall
> > >
> > >
> > >
> > > ----- Original Message -----
> > > From: "David Graham" <gr...@yahoo.com>
> > > To: "Struts Developers List" <st...@jakarta.apache.org>
> > > Sent: Friday, January 16, 2004 1:39 PM
> > > Subject: Re: Validating Formatted Numbers Patch [Bugzilla 26151]
> > >
> > >
> > > >
> > > > --- Niall Pemberton <ni...@blueyonder.co.uk> 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" <gr...@yahoo.com>
> > > > > To: "Struts Developers List" <st...@jakarta.apache.org>
> > > > > 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 <ni...@blueyonder.co.uk> 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:
> > > struts-dev-unsubscribe@jakarta.apache.org
> > > > > > > For additional commands, e-mail:
> > > struts-dev-help@jakarta.apache.org
> > > > > > >
> > > > > >
> > >
> > === message truncated ===
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
> > http://hotjobs.sweepstakes.yahoo.com/signingbonus
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


Re: Validating Formatted Numbers Patch [Bugzilla 26151]

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
Caused me some grief....plus a complete lack knowledge of RegExp until
yesterday. Anyway, thanks to everyone for the help and input - I know more
today than I did yesterday.

I've put a enhancement request into Bugzilla with patch on Commons to change
this - fingers crossed it will be approved.

Niall

----- Original Message ----- 
From: "Richard Hightower" <rh...@arc-mind.com>
To: "Struts Developers List" <st...@jakarta.apache.org>
Sent: Friday, January 16, 2004 6:00 PM
Subject: RE: Validating Formatted Numbers Patch [Bugzilla 26151]


> Niall,
>
> Good catch!
>
> I was wondering why I had to always specify ^ and $.
>
> I wrote a few of my own validator rules (e.g., zip code and phone number),
> and I used regex from java.
> I used the match function. This explains some mysteries in my head.
>
>
>
>
> -----Original Message-----
> From: Niall Pemberton [mailto:niall.pemberton@blueyonder.co.uk]
> Sent: Friday, January 16, 2004 8:30 AM
> To: Struts Developers List
> Subject: Re: Validating Formatted Numbers Patch [Bugzilla 26151]
>
>
> I already tried it, and it is backward compatible. The thing about
Perl5Util
> is it provides a convinience method
> of match(value, pattern) which creates a Perl5Compiler, builds a cache of
> compiled patterns and calls the Perl5Matcher.contains()
> method. There isn't an equivalent convinience method that calls the
> Perl5Matcher.matches() method.
>
> Replacing:
> boolean match = Perl5Util.match(value, pattern)
>
> requires:
>
> Perl5Compiler compiler = new Perl5Compiler();
> Pattern compiledPattern = compiler.compile(pattern);
> Perl5Matcher matcher   = new Perl5Matcher();
> boolean match = matcher.matches(value, compiledPattern);
>
> But then, it would be less efficient as the pattern is being compiled
every
> time. It would be
> straight forward to do the equivalent of Perl5Util and create a cache.
>
> I might have a look at this later and submit a patch to Commons.
>
> Niall
>
> ----- Original Message -----
> >  "David Graham" <gr...@yahoo.com> wrote:
> >
> > --- Niall Pemberton <ni...@blueyonder.co.uk> wrote:
> > > Hey thanks for your help - what you suggested worked (i.e. using
> > > "^[\d,]*$") - I was using the ORO demo, but if you don't put the right
> > > stuff
> > > in....:-)
> > >
> > > OK, I'm picking up regex slowly - so this works because ^ is for the
> > > beginning of a line and % is for the end of a line.
> >
> > I think you meant $ instead of % but yes that's correct.
> >
> > >
> > > Apologies for the "doesn't work" slander then - but wouldn't it be
> > > better to
> > > use Perl5Matcher.matches(value, pattern) and then there would be no
need
> > > to
> > > specify the ^ and $ characters at the start and end - simpler and less
> > > confusing?
> > >
> > > This could be done and would be backward compatible.
> >
> > I really haven't looked at the differences between matches() and
> > contains() so I don't know if it's backwards compatible.  You could try
> > changing it and let us know what happens.
> >
> > David
> >
> > >
> > > Niall
> > >
> > >
> > >
> > > ----- Original Message -----
> > > From: "David Graham" <gr...@yahoo.com>
> > > To: "Struts Developers List" <st...@jakarta.apache.org>
> > > Sent: Friday, January 16, 2004 1:39 PM
> > > Subject: Re: Validating Formatted Numbers Patch [Bugzilla 26151]
> > >
> > >
> > > >
> > > > --- Niall Pemberton <ni...@blueyonder.co.uk> 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" <gr...@yahoo.com>
> > > > > To: "Struts Developers List" <st...@jakarta.apache.org>
> > > > > 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 <ni...@blueyonder.co.uk> 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:
> > > struts-dev-unsubscribe@jakarta.apache.org
> > > > > > > For additional commands, e-mail:
> > > struts-dev-help@jakarta.apache.org
> > > > > > >
> > > > > >
> > >
> > === message truncated ===
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
> > http://hotjobs.sweepstakes.yahoo.com/signingbonus
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


RE: Validating Formatted Numbers Patch [Bugzilla 26151]

Posted by Richard Hightower <rh...@arc-mind.com>.
Niall,

Good catch!

I was wondering why I had to always specify ^ and $.

I wrote a few of my own validator rules (e.g., zip code and phone number),
and I used regex from java.
I used the match function. This explains some mysteries in my head.




-----Original Message-----
From: Niall Pemberton [mailto:niall.pemberton@blueyonder.co.uk]
Sent: Friday, January 16, 2004 8:30 AM
To: Struts Developers List
Subject: Re: Validating Formatted Numbers Patch [Bugzilla 26151]


I already tried it, and it is backward compatible. The thing about Perl5Util
is it provides a convinience method
of match(value, pattern) which creates a Perl5Compiler, builds a cache of
compiled patterns and calls the Perl5Matcher.contains()
method. There isn't an equivalent convinience method that calls the
Perl5Matcher.matches() method.

Replacing:
boolean match = Perl5Util.match(value, pattern)

requires:

Perl5Compiler compiler = new Perl5Compiler();
Pattern compiledPattern = compiler.compile(pattern);
Perl5Matcher matcher   = new Perl5Matcher();
boolean match = matcher.matches(value, compiledPattern);

But then, it would be less efficient as the pattern is being compiled every
time. It would be
straight forward to do the equivalent of Perl5Util and create a cache.

I might have a look at this later and submit a patch to Commons.

Niall

----- Original Message -----
>  "David Graham" <gr...@yahoo.com> wrote:
>
> --- Niall Pemberton <ni...@blueyonder.co.uk> wrote:
> > Hey thanks for your help - what you suggested worked (i.e. using
> > "^[\d,]*$") - I was using the ORO demo, but if you don't put the right
> > stuff
> > in....:-)
> >
> > OK, I'm picking up regex slowly - so this works because ^ is for the
> > beginning of a line and % is for the end of a line.
>
> I think you meant $ instead of % but yes that's correct.
>
> >
> > Apologies for the "doesn't work" slander then - but wouldn't it be
> > better to
> > use Perl5Matcher.matches(value, pattern) and then there would be no need
> > to
> > specify the ^ and $ characters at the start and end - simpler and less
> > confusing?
> >
> > This could be done and would be backward compatible.
>
> I really haven't looked at the differences between matches() and
> contains() so I don't know if it's backwards compatible.  You could try
> changing it and let us know what happens.
>
> David
>
> >
> > Niall
> >
> >
> >
> > ----- Original Message -----
> > From: "David Graham" <gr...@yahoo.com>
> > To: "Struts Developers List" <st...@jakarta.apache.org>
> > Sent: Friday, January 16, 2004 1:39 PM
> > Subject: Re: Validating Formatted Numbers Patch [Bugzilla 26151]
> >
> >
> > >
> > > --- Niall Pemberton <ni...@blueyonder.co.uk> 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" <gr...@yahoo.com>
> > > > To: "Struts Developers List" <st...@jakarta.apache.org>
> > > > 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 <ni...@blueyonder.co.uk> 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:
> > struts-dev-unsubscribe@jakarta.apache.org
> > > > > > For additional commands, e-mail:
> > struts-dev-help@jakarta.apache.org
> > > > > >
> > > > >
> >
> === message truncated ===
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
> http://hotjobs.sweepstakes.yahoo.com/signingbonus
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


Re: Validating Formatted Numbers Patch [Bugzilla 26151]

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
I already tried it, and it is backward compatible. The thing about Perl5Util
is it provides a convinience method
of match(value, pattern) which creates a Perl5Compiler, builds a cache of
compiled patterns and calls the Perl5Matcher.contains()
method. There isn't an equivalent convinience method that calls the
Perl5Matcher.matches() method.

Replacing:
boolean match = Perl5Util.match(value, pattern)

requires:

Perl5Compiler compiler = new Perl5Compiler();
Pattern compiledPattern = compiler.compile(pattern);
Perl5Matcher matcher   = new Perl5Matcher();
boolean match = matcher.matches(value, compiledPattern);

But then, it would be less efficient as the pattern is being compiled every
time. It would be
straight forward to do the equivalent of Perl5Util and create a cache.

I might have a look at this later and submit a patch to Commons.

Niall

----- Original Message ----- 
>  "David Graham" <gr...@yahoo.com> wrote:
>
> --- Niall Pemberton <ni...@blueyonder.co.uk> wrote:
> > Hey thanks for your help - what you suggested worked (i.e. using
> > "^[\d,]*$") - I was using the ORO demo, but if you don't put the right
> > stuff
> > in....:-)
> >
> > OK, I'm picking up regex slowly - so this works because ^ is for the
> > beginning of a line and % is for the end of a line.
>
> I think you meant $ instead of % but yes that's correct.
>
> >
> > Apologies for the "doesn't work" slander then - but wouldn't it be
> > better to
> > use Perl5Matcher.matches(value, pattern) and then there would be no need
> > to
> > specify the ^ and $ characters at the start and end - simpler and less
> > confusing?
> >
> > This could be done and would be backward compatible.
>
> I really haven't looked at the differences between matches() and
> contains() so I don't know if it's backwards compatible.  You could try
> changing it and let us know what happens.
>
> David
>
> >
> > Niall
> >
> >
> >
> > ----- Original Message ----- 
> > From: "David Graham" <gr...@yahoo.com>
> > To: "Struts Developers List" <st...@jakarta.apache.org>
> > Sent: Friday, January 16, 2004 1:39 PM
> > Subject: Re: Validating Formatted Numbers Patch [Bugzilla 26151]
> >
> >
> > >
> > > --- Niall Pemberton <ni...@blueyonder.co.uk> 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" <gr...@yahoo.com>
> > > > To: "Struts Developers List" <st...@jakarta.apache.org>
> > > > 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 <ni...@blueyonder.co.uk> 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:
> > struts-dev-unsubscribe@jakarta.apache.org
> > > > > > For additional commands, e-mail:
> > struts-dev-help@jakarta.apache.org
> > > > > >
> > > > >
> >
> === message truncated ===
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
> http://hotjobs.sweepstakes.yahoo.com/signingbonus
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


Re: Validating Formatted Numbers Patch [Bugzilla 26151]

Posted by David Graham <gr...@yahoo.com>.
--- Niall Pemberton <ni...@blueyonder.co.uk> wrote:
> Hey thanks for your help - what you suggested worked (i.e. using
> "^[\d,]*$") - I was using the ORO demo, but if you don't put the right
> stuff
> in....:-)
> 
> OK, I'm picking up regex slowly - so this works because ^ is for the
> beginning of a line and % is for the end of a line.

I think you meant $ instead of % but yes that's correct.

> 
> Apologies for the "doesn't work" slander then - but wouldn't it be
> better to
> use Perl5Matcher.matches(value, pattern) and then there would be no need
> to
> specify the ^ and $ characters at the start and end - simpler and less
> confusing?
> 
> This could be done and would be backward compatible.

I really haven't looked at the differences between matches() and
contains() so I don't know if it's backwards compatible.  You could try
changing it and let us know what happens.

David

> 
> Niall
> 
> 
> 
> ----- Original Message ----- 
> From: "David Graham" <gr...@yahoo.com>
> To: "Struts Developers List" <st...@jakarta.apache.org>
> Sent: Friday, January 16, 2004 1:39 PM
> Subject: Re: Validating Formatted Numbers Patch [Bugzilla 26151]
> 
> 
> >
> > --- Niall Pemberton <ni...@blueyonder.co.uk> 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" <gr...@yahoo.com>
> > > To: "Struts Developers List" <st...@jakarta.apache.org>
> > > 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 <ni...@blueyonder.co.uk> 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:
> struts-dev-unsubscribe@jakarta.apache.org
> > > > > For additional commands, e-mail:
> struts-dev-help@jakarta.apache.org
> > > > >
> > > >
> 
=== message truncated ===


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

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


Re: Validating Formatted Numbers Patch [Bugzilla 26151]

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
Hey thanks for your help - what you suggested worked (i.e. using
"^[\d,]*$") - I was using the ORO demo, but if you don't put the right stuff
in....:-)

OK, I'm picking up regex slowly - so this works because ^ is for the
beginning of a line and % is for the end of a line.

Apologies for the "doesn't work" slander then - but wouldn't it be better to
use Perl5Matcher.matches(value, pattern) and then there would be no need to
specify the ^ and $ characters at the start and end - simpler and less
confusing?

This could be done and would be backward compatible.

Niall



----- Original Message ----- 
From: "David Graham" <gr...@yahoo.com>
To: "Struts Developers List" <st...@jakarta.apache.org>
Sent: Friday, January 16, 2004 1:39 PM
Subject: Re: Validating Formatted Numbers Patch [Bugzilla 26151]


>
> --- Niall Pemberton <ni...@blueyonder.co.uk> 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" <gr...@yahoo.com>
> > To: "Struts Developers List" <st...@jakarta.apache.org>
> > 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 <ni...@blueyonder.co.uk> 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: struts-dev-unsubscribe@jakarta.apache.org
> > > > For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> > > >
> > >
> > >
> > > __________________________________
> > > Do you Yahoo!?
> > > Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
> > > http://hotjobs.sweepstakes.yahoo.com/signingbonus
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> > >
> > >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> >
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
> http://hotjobs.sweepstakes.yahoo.com/signingbonus
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


Re: Validating Formatted Numbers Patch [Bugzilla 26151]

Posted by David Graham <gr...@yahoo.com>.
--- Niall Pemberton <ni...@blueyonder.co.uk> 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" <gr...@yahoo.com>
> To: "Struts Developers List" <st...@jakarta.apache.org>
> 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 <ni...@blueyonder.co.uk> 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: struts-dev-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> > >
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
> > http://hotjobs.sweepstakes.yahoo.com/signingbonus
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> >
> >
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> 


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

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


RE: Validating Formatted Numbers Patch [Bugzilla 26151]

Posted by Richard Hightower <rh...@arc-mind.com>.
I can vouch that the mask works.

Send me your complete xml file or at least cut and paste the field element
in the email and I will take a look.


-----Original Message-----
From: Niall Pemberton [mailto:niall.pemberton@blueyonder.co.uk]
Sent: Friday, January 16, 2004 5:03 AM
To: Struts Developers List
Subject: Re: Validating Formatted Numbers Patch [Bugzilla 26151]


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

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" <gr...@yahoo.com>
To: "Struts Developers List" <st...@jakarta.apache.org>
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 <ni...@blueyonder.co.uk> 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: struts-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> >
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
> http://hotjobs.sweepstakes.yahoo.com/signingbonus
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


Re: Validating Formatted Numbers Patch [Bugzilla 26151]

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
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 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.

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" <gr...@yahoo.com>
To: "Struts Developers List" <st...@jakarta.apache.org>
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 <ni...@blueyonder.co.uk> 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: struts-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> >
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
> http://hotjobs.sweepstakes.yahoo.com/signingbonus
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


Re: Validating Formatted Numbers Patch [Bugzilla 26151]

Posted by Sgarlata Matt <sg...@bah.com>.
Niall -

If you do add on to this patch to support JavaScript validations of
numberFormats, there is probably some existing JavaScript code available
that you can use.  I would start by looking at Matt Kruse's JavaScript Date
Functions, which you can find here:

http://www.mattkruse.com/javascript/date/

Matt
----- Original Message ----- 
From: "Niall Pemberton" <ni...@blueyonder.co.uk>
To: "Struts Developers List" <st...@jakarta.apache.org>
Sent: Friday, January 16, 2004 9:48 AM
Subject: Re: Validating Formatted Numbers Patch [Bugzilla 26151]


> OK hey, appreciate your feedback - and the mask/regexp gives me another
> string to my bow!
>
> I do think using the DecimalFormat style patterns is much easier and
> intuitive, but there is the issue
> over JavaScript and there are issues with the DecimalFormat parse()
method.
> I think I need to
> re-think this enhacement request so I'll drop it for the moment and
perhaps
> submit something different
> at a later date.
>
> Niall
>
> ----- Original Message ----- 
> From: "David Graham" <gr...@yahoo.com>
> To: "Struts Developers List" <st...@jakarta.apache.org>
> Sent: Friday, January 16, 2004 1:46 PM
> Subject: Re: Validating Formatted Numbers Patch [Bugzilla 26151]
>
>
> >
> > --- Niall Pemberton <ni...@blueyonder.co.uk> wrote:
> > > I agree with both of you!
> > >
> > > Not having JavaScript implementation shouldn't be an issue - if people
> > > want
> > > it then someone would come up with it.
> > >
> > > However, because the approach I took was to modify the exiting number
> > > validations (byte, short, long, integer, float, double) then it means
> > > that where there is JavaScript validation (not all of them seem to
have)
> > > these will now fail if a pattern is used, because they don't take into
> > > account the pattern.
> > >
> > > I would put some additional time on this, if a committer was willing
to
> > > implement it. But since David Graham has said he is -1 on this,
doesn't
> > > that
> > > effectively make this enhacement request dead?
> >
> > There wasn't a vote so my -1 is more of an indication that I don't like
> > the idea.  Mask is the most flexible validation that allows many things
> > like formatted number validations.  If you can't get your regex to work
> > you might try writing a custom validation action that uses
DecimalFormat.
> > If that works you could post a patch to bugzilla.  I encourage you to
get
> > the regex to work though because it will make life easier in the long
run
> > :-).
> >
> > David
> >
> > >
> > > Niall
> > >
> > >
> > > Richard Hightower wrote ...
> > > > I agree about that sticky wicket, but....
> > > >
> > > > There are already validation rules that do not have client-side
> > > support
> > > (via
> > > > JavaScript).
> > > >
> > > > At least this type of stuff would be nice in the contrib area.
> > > >
> > >
> > > Ted Husted wrote ...
> > > > In principle, I'd agree with Rick, since these type of patterns are
> > > the
> > > > standard way of doing this sort of thing on the Java platform.
> > > >
> > > > But, the sticky wicket is lack of a JavaScript implementation.
People
> > > would
> > > > expect an implementation like this to include client-side support,
as
> > > the
> > > > other validations do.
> > > >
> > > > -Ted.
> > > >
> > > >
> > > > On Thu, 15 Jan 2004 20:54:17 -0700, Richard Hightower wrote:
> > > > > Niall,
> > > > >
> > > > >
> > > > > I don't get a vote. I am not a committer. But if I did.... I would
> > > > > vote +1 on the idea (I have not studied your implementation). I
can
> > > > > write regular expressions in a pinch, but why not support all of
> > > > > the java.text.* in the validator rules (including currencey). I
> > > > > like the idea.
> > > > >
> > > > > Rick Hightower
> > > > > Developer
> > > > >
> > > > >
> > > > > Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
> > > > > Struts/J2EE consulting -- http://www.arc-
> > > > > mind.com/consulting.htm#StrutsMentoring
> > > > >
> > > > > -----Original Message-----
> > > > > From: Niall Pemberton [mailto:niall.pemberton@blueyonder.co.uk]
> > > > > Sent: Thursday, January 15, 2004 5:38 PM To: Struts Developers
List
> > > > > Subject: Re: Validating Formatted Numbers Patch [Bugzilla 26151]
> > > > >
> > > > >
> > > > > OK so how can it be done with mask?
> > > > >
> > > > >
> > > > > also, it doesn't get more basic than numbers...if it can be done
> > > > > with mask, but its complicated, doesn't ease of use cut any ice?
> > > > >
> > > > > Niall
> > > > > ----- Original Message -----
> > > > > From: "David Graham" <gr...@yahoo.com>
> > > > > To: "Struts Developers List" <st...@jakarta.apache.org> 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 <ni...@blueyonder.co.uk> 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: struts-dev-
> > > > >>> unsubscribe@jakarta.apache.org For additional commands, e-mail:
> > > > >>> struts-dev-help@jakarta.apache.org
> > > > >>
> > > > >>
> > > > >> __________________________________
> > > > >> Do you Yahoo!?
> > > > >> Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
> > > > >> http://hotjobs.sweepstakes.yahoo.com/signingbonus
> > > > >>
> > > > >>
> > > >
>> ------------------------------------------------------------------
> > > > >> --- To unsubscribe, e-mail: struts-dev-
> > > > >> unsubscribe@jakarta.apache.org For additional commands, e-mail:
> > > > >> struts-dev-help@jakarta.apache.org
> > > > >
> > > > >
> > > >
> --------------------------------------------------------------------
> > > > > - To unsubscribe, e-mail:
struts-dev-unsubscribe@jakarta.apache.org
> > > > > For additional commands, e-mail:
struts-dev-help@jakarta.apache.org
> > > > >
> > > > >
> > > >
> --------------------------------------------------------------------
> > > > > - To unsubscribe, e-mail:
struts-dev-unsubscribe@jakarta.apache.org
> > > > > For additional commands, e-mail:
struts-dev-help@jakarta.apache.org
> > > >
> > > >
> > > >
> > > >
> > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> > > > For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> > >
> > === message truncated ===
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
> > http://hotjobs.sweepstakes.yahoo.com/signingbonus
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


Re: Validating Formatted Numbers Patch [Bugzilla 26151]

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
OK hey, appreciate your feedback - and the mask/regexp gives me another
string to my bow!

I do think using the DecimalFormat style patterns is much easier and
intuitive, but there is the issue
over JavaScript and there are issues with the DecimalFormat parse() method.
I think I need to
re-think this enhacement request so I'll drop it for the moment and perhaps
submit something different
at a later date.

Niall

----- Original Message ----- 
From: "David Graham" <gr...@yahoo.com>
To: "Struts Developers List" <st...@jakarta.apache.org>
Sent: Friday, January 16, 2004 1:46 PM
Subject: Re: Validating Formatted Numbers Patch [Bugzilla 26151]


>
> --- Niall Pemberton <ni...@blueyonder.co.uk> wrote:
> > I agree with both of you!
> >
> > Not having JavaScript implementation shouldn't be an issue - if people
> > want
> > it then someone would come up with it.
> >
> > However, because the approach I took was to modify the exiting number
> > validations (byte, short, long, integer, float, double) then it means
> > that where there is JavaScript validation (not all of them seem to have)
> > these will now fail if a pattern is used, because they don't take into
> > account the pattern.
> >
> > I would put some additional time on this, if a committer was willing to
> > implement it. But since David Graham has said he is -1 on this, doesn't
> > that
> > effectively make this enhacement request dead?
>
> There wasn't a vote so my -1 is more of an indication that I don't like
> the idea.  Mask is the most flexible validation that allows many things
> like formatted number validations.  If you can't get your regex to work
> you might try writing a custom validation action that uses DecimalFormat.
> If that works you could post a patch to bugzilla.  I encourage you to get
> the regex to work though because it will make life easier in the long run
> :-).
>
> David
>
> >
> > Niall
> >
> >
> > Richard Hightower wrote ...
> > > I agree about that sticky wicket, but....
> > >
> > > There are already validation rules that do not have client-side
> > support
> > (via
> > > JavaScript).
> > >
> > > At least this type of stuff would be nice in the contrib area.
> > >
> >
> > Ted Husted wrote ...
> > > In principle, I'd agree with Rick, since these type of patterns are
> > the
> > > standard way of doing this sort of thing on the Java platform.
> > >
> > > But, the sticky wicket is lack of a JavaScript implementation. People
> > would
> > > expect an implementation like this to include client-side support, as
> > the
> > > other validations do.
> > >
> > > -Ted.
> > >
> > >
> > > On Thu, 15 Jan 2004 20:54:17 -0700, Richard Hightower wrote:
> > > > Niall,
> > > >
> > > >
> > > > I don't get a vote. I am not a committer. But if I did.... I would
> > > > vote +1 on the idea (I have not studied your implementation). I can
> > > > write regular expressions in a pinch, but why not support all of
> > > > the java.text.* in the validator rules (including currencey). I
> > > > like the idea.
> > > >
> > > > Rick Hightower
> > > > Developer
> > > >
> > > >
> > > > Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
> > > > Struts/J2EE consulting -- http://www.arc-
> > > > mind.com/consulting.htm#StrutsMentoring
> > > >
> > > > -----Original Message-----
> > > > From: Niall Pemberton [mailto:niall.pemberton@blueyonder.co.uk]
> > > > Sent: Thursday, January 15, 2004 5:38 PM To: Struts Developers List
> > > > Subject: Re: Validating Formatted Numbers Patch [Bugzilla 26151]
> > > >
> > > >
> > > > OK so how can it be done with mask?
> > > >
> > > >
> > > > also, it doesn't get more basic than numbers...if it can be done
> > > > with mask, but its complicated, doesn't ease of use cut any ice?
> > > >
> > > > Niall
> > > > ----- Original Message -----
> > > > From: "David Graham" <gr...@yahoo.com>
> > > > To: "Struts Developers List" <st...@jakarta.apache.org> 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 <ni...@blueyonder.co.uk> 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: struts-dev-
> > > >>> unsubscribe@jakarta.apache.org For additional commands, e-mail:
> > > >>> struts-dev-help@jakarta.apache.org
> > > >>
> > > >>
> > > >> __________________________________
> > > >> Do you Yahoo!?
> > > >> Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
> > > >> http://hotjobs.sweepstakes.yahoo.com/signingbonus
> > > >>
> > > >>
> > > >> ------------------------------------------------------------------
> > > >> --- To unsubscribe, e-mail: struts-dev-
> > > >> unsubscribe@jakarta.apache.org For additional commands, e-mail:
> > > >> struts-dev-help@jakarta.apache.org
> > > >
> > > >
> > > > --------------------------------------------------------------------
> > > > - To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> > > > For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> > > >
> > > >
> > > > --------------------------------------------------------------------
> > > > - To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> > > > For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> > >
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> >
> === message truncated ===
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
> http://hotjobs.sweepstakes.yahoo.com/signingbonus
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


Re: Validating Formatted Numbers Patch [Bugzilla 26151]

Posted by David Graham <gr...@yahoo.com>.
--- Niall Pemberton <ni...@blueyonder.co.uk> wrote:
> I agree with both of you!
> 
> Not having JavaScript implementation shouldn't be an issue - if people
> want
> it then someone would come up with it.
> 
> However, because the approach I took was to modify the exiting number
> validations (byte, short, long, integer, float, double) then it means
> that where there is JavaScript validation (not all of them seem to have)
> these will now fail if a pattern is used, because they don't take into
> account the pattern.
> 
> I would put some additional time on this, if a committer was willing to
> implement it. But since David Graham has said he is -1 on this, doesn't
> that
> effectively make this enhacement request dead?

There wasn't a vote so my -1 is more of an indication that I don't like
the idea.  Mask is the most flexible validation that allows many things
like formatted number validations.  If you can't get your regex to work
you might try writing a custom validation action that uses DecimalFormat. 
If that works you could post a patch to bugzilla.  I encourage you to get
the regex to work though because it will make life easier in the long run
:-).

David

> 
> Niall
> 
> 
> Richard Hightower wrote ...
> > I agree about that sticky wicket, but....
> >
> > There are already validation rules that do not have client-side
> support
> (via
> > JavaScript).
> >
> > At least this type of stuff would be nice in the contrib area.
> >
> 
> Ted Husted wrote ...
> > In principle, I'd agree with Rick, since these type of patterns are
> the
> > standard way of doing this sort of thing on the Java platform.
> >
> > But, the sticky wicket is lack of a JavaScript implementation. People
> would
> > expect an implementation like this to include client-side support, as
> the
> > other validations do.
> >
> > -Ted.
> >
> >
> > On Thu, 15 Jan 2004 20:54:17 -0700, Richard Hightower wrote:
> > > Niall,
> > >
> > >
> > > I don't get a vote. I am not a committer. But if I did.... I would
> > > vote +1 on the idea (I have not studied your implementation). I can
> > > write regular expressions in a pinch, but why not support all of
> > > the java.text.* in the validator rules (including currencey). I
> > > like the idea.
> > >
> > > Rick Hightower
> > > Developer
> > >
> > >
> > > Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
> > > Struts/J2EE consulting -- http://www.arc-
> > > mind.com/consulting.htm#StrutsMentoring
> > >
> > > -----Original Message-----
> > > From: Niall Pemberton [mailto:niall.pemberton@blueyonder.co.uk]
> > > Sent: Thursday, January 15, 2004 5:38 PM To: Struts Developers List
> > > Subject: Re: Validating Formatted Numbers Patch [Bugzilla 26151]
> > >
> > >
> > > OK so how can it be done with mask?
> > >
> > >
> > > also, it doesn't get more basic than numbers...if it can be done
> > > with mask, but its complicated, doesn't ease of use cut any ice?
> > >
> > > Niall
> > > ----- Original Message -----
> > > From: "David Graham" <gr...@yahoo.com>
> > > To: "Struts Developers List" <st...@jakarta.apache.org> 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 <ni...@blueyonder.co.uk> 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: struts-dev-
> > >>> unsubscribe@jakarta.apache.org For additional commands, e-mail:
> > >>> struts-dev-help@jakarta.apache.org
> > >>
> > >>
> > >> __________________________________
> > >> Do you Yahoo!?
> > >> Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
> > >> http://hotjobs.sweepstakes.yahoo.com/signingbonus
> > >>
> > >>
> > >> ------------------------------------------------------------------
> > >> --- To unsubscribe, e-mail: struts-dev-
> > >> unsubscribe@jakarta.apache.org For additional commands, e-mail:
> > >> struts-dev-help@jakarta.apache.org
> > >
> > >
> > > --------------------------------------------------------------------
> > > - To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> > >
> > >
> > > --------------------------------------------------------------------
> > > - To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> 
=== message truncated ===


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

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


Re: Validating Formatted Numbers Patch [Bugzilla 26151]

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
I agree with both of you!

Not having JavaScript implementation shouldn't be an issue - if people want
it then someone would come up with it.

However, because the approach I took was to modify the exiting number
validations (byte, short, long, integer, float, double) then it means
that where there is JavaScript validation (not all of them seem to have)
these will now fail if a pattern is used, because they don't take into
account the pattern.

I would put some additional time on this, if a committer was willing to
implement it. But since David Graham has said he is -1 on this, doesn't that
effectively make this enhacement request dead?

Niall


Richard Hightower wrote ...
> I agree about that sticky wicket, but....
>
> There are already validation rules that do not have client-side support
(via
> JavaScript).
>
> At least this type of stuff would be nice in the contrib area.
>

Ted Husted wrote ...
> In principle, I'd agree with Rick, since these type of patterns are the
> standard way of doing this sort of thing on the Java platform.
>
> But, the sticky wicket is lack of a JavaScript implementation. People
would
> expect an implementation like this to include client-side support, as the
> other validations do.
>
> -Ted.
>
>
> On Thu, 15 Jan 2004 20:54:17 -0700, Richard Hightower wrote:
> > Niall,
> >
> >
> > I don't get a vote. I am not a committer. But if I did.... I would
> > vote +1 on the idea (I have not studied your implementation). I can
> > write regular expressions in a pinch, but why not support all of
> > the java.text.* in the validator rules (including currencey). I
> > like the idea.
> >
> > Rick Hightower
> > Developer
> >
> >
> > Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
> > Struts/J2EE consulting -- http://www.arc-
> > mind.com/consulting.htm#StrutsMentoring
> >
> > -----Original Message-----
> > From: Niall Pemberton [mailto:niall.pemberton@blueyonder.co.uk]
> > Sent: Thursday, January 15, 2004 5:38 PM To: Struts Developers List
> > Subject: Re: Validating Formatted Numbers Patch [Bugzilla 26151]
> >
> >
> > OK so how can it be done with mask?
> >
> >
> > also, it doesn't get more basic than numbers...if it can be done
> > with mask, but its complicated, doesn't ease of use cut any ice?
> >
> > Niall
> > ----- Original Message -----
> > From: "David Graham" <gr...@yahoo.com>
> > To: "Struts Developers List" <st...@jakarta.apache.org> 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 <ni...@blueyonder.co.uk> 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: struts-dev-
> >>> unsubscribe@jakarta.apache.org For additional commands, e-mail:
> >>> struts-dev-help@jakarta.apache.org
> >>
> >>
> >> __________________________________
> >> Do you Yahoo!?
> >> Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
> >> http://hotjobs.sweepstakes.yahoo.com/signingbonus
> >>
> >>
> >> ------------------------------------------------------------------
> >> --- To unsubscribe, e-mail: struts-dev-
> >> unsubscribe@jakarta.apache.org For additional commands, e-mail:
> >> struts-dev-help@jakarta.apache.org
> >
> >
> > --------------------------------------------------------------------
> > - To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> >
> >
> > --------------------------------------------------------------------
> > - To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-dev-help@jakarta.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


RE: Validating Formatted Numbers Patch [Bugzilla 26151]

Posted by Richard Hightower <rh...@arc-mind.com>.
I agree about that sticky wicket, but....

There are already validation rules that do not have client-side support (via
JavaScript).

At least this type of stuff would be nice in the contrib area.

-----Original Message-----
From: Ted Husted [mailto:husted@apache.org]
Sent: Thursday, January 15, 2004 9:10 PM
To: Struts Developers List
Subject: RE: Validating Formatted Numbers Patch [Bugzilla 26151]


In principle, I'd agree with Rick, since these type of patterns are the
standard way of doing this sort of thing on the Java platform.

But, the sticky wicket is lack of a JavaScript implementation. People would
expect an implementation like this to include client-side support, as the
other validations do.

-Ted.


On Thu, 15 Jan 2004 20:54:17 -0700, Richard Hightower wrote:
> Niall,
>
>
> I don't get a vote. I am not a committer. But if I did.... I would
> vote +1 on the idea (I have not studied your implementation). I can
> write regular expressions in a pinch, but why not support all of
> the java.text.* in the validator rules (including currencey). I
> like the idea.
>
> Rick Hightower
> Developer
>
>
> Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
> Struts/J2EE consulting -- http://www.arc-
> mind.com/consulting.htm#StrutsMentoring
>
> -----Original Message-----
> From: Niall Pemberton [mailto:niall.pemberton@blueyonder.co.uk]
> Sent: Thursday, January 15, 2004 5:38 PM To: Struts Developers List
> Subject: Re: Validating Formatted Numbers Patch [Bugzilla 26151]
>
>
> OK so how can it be done with mask?
>
>
> also, it doesn't get more basic than numbers...if it can be done
> with mask, but its complicated, doesn't ease of use cut any ice?
>
> Niall
> ----- Original Message -----
> From: "David Graham" <gr...@yahoo.com>
> To: "Struts Developers List" <st...@jakarta.apache.org> 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 <ni...@blueyonder.co.uk> 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: struts-dev-
>>> unsubscribe@jakarta.apache.org For additional commands, e-mail:
>>> struts-dev-help@jakarta.apache.org
>>
>>
>> __________________________________
>> Do you Yahoo!?
>> Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
>> http://hotjobs.sweepstakes.yahoo.com/signingbonus
>>
>>
>> ------------------------------------------------------------------
>> --- To unsubscribe, e-mail: struts-dev-
>> unsubscribe@jakarta.apache.org For additional commands, e-mail:
>> struts-dev-help@jakarta.apache.org
>
>
> --------------------------------------------------------------------
> - To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org
>
>
> --------------------------------------------------------------------
> - To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


RE: Validating Formatted Numbers Patch [Bugzilla 26151]

Posted by Ted Husted <hu...@apache.org>.
In principle, I'd agree with Rick, since these type of patterns are the standard way of doing this sort of thing on the Java platform. 

But, the sticky wicket is lack of a JavaScript implementation. People would expect an implementation like this to include client-side support, as the other validations do. 

-Ted.


On Thu, 15 Jan 2004 20:54:17 -0700, Richard Hightower wrote:
> Niall,
>
>
> I don't get a vote. I am not a committer. But if I did.... I would
> vote +1 on the idea (I have not studied your implementation). I can
> write regular expressions in a pinch, but why not support all of
> the java.text.* in the validator rules (including currencey). I
> like the idea.
>
> Rick Hightower
> Developer
>
>
> Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
> Struts/J2EE consulting -- http://www.arc-
> mind.com/consulting.htm#StrutsMentoring
>
> -----Original Message-----
> From: Niall Pemberton [mailto:niall.pemberton@blueyonder.co.uk]
> Sent: Thursday, January 15, 2004 5:38 PM To: Struts Developers List
> Subject: Re: Validating Formatted Numbers Patch [Bugzilla 26151]
>
>
> OK so how can it be done with mask?
>
>
> also, it doesn't get more basic than numbers...if it can be done
> with mask, but its complicated, doesn't ease of use cut any ice?
>
> Niall
> ----- Original Message -----
> From: "David Graham" <gr...@yahoo.com>
> To: "Struts Developers List" <st...@jakarta.apache.org> 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 <ni...@blueyonder.co.uk> 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: struts-dev-
>>> unsubscribe@jakarta.apache.org For additional commands, e-mail:
>>> struts-dev-help@jakarta.apache.org
>>
>>
>> __________________________________
>> Do you Yahoo!?
>> Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
>> http://hotjobs.sweepstakes.yahoo.com/signingbonus
>>
>>
>> ------------------------------------------------------------------
>> --- To unsubscribe, e-mail: struts-dev-
>> unsubscribe@jakarta.apache.org For additional commands, e-mail:
>> struts-dev-help@jakarta.apache.org
>
>
> --------------------------------------------------------------------
> - To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org
>
>
> --------------------------------------------------------------------
> - To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


RE: Validating Formatted Numbers Patch [Bugzilla 26151]

Posted by Richard Hightower <rh...@arc-mind.com>.
Niall,

I don't get a vote. I am not a committer. But if I did.... I would vote +1
on the idea (I have not studied your implementation). I can write regular
expressions in a pinch, but why not support all of the java.text.* in the
validator rules (including currencey). I like the idea.

Rick Hightower
Developer

Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
Struts/J2EE consulting --
http://www.arc-mind.com/consulting.htm#StrutsMentoring

-----Original Message-----
From: Niall Pemberton [mailto:niall.pemberton@blueyonder.co.uk]
Sent: Thursday, January 15, 2004 5:38 PM
To: Struts Developers List
Subject: Re: Validating Formatted Numbers Patch [Bugzilla 26151]


OK so how can it be done with mask?

also, it doesn't get more basic than numbers...if it can be done with mask,
but its complicated, doesn't ease of use cut any ice?

Niall
----- Original Message -----
From: "David Graham" <gr...@yahoo.com>
To: "Struts Developers List" <st...@jakarta.apache.org>
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 <ni...@blueyonder.co.uk> 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: struts-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> >
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
> http://hotjobs.sweepstakes.yahoo.com/signingbonus
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


Re: Validating Formatted Numbers Patch [Bugzilla 26151]

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
OK so how can it be done with mask?

also, it doesn't get more basic than numbers...if it can be done with mask,
but its complicated, doesn't ease of use cut any ice?

Niall
----- Original Message ----- 
From: "David Graham" <gr...@yahoo.com>
To: "Struts Developers List" <st...@jakarta.apache.org>
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 <ni...@blueyonder.co.uk> 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: struts-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> >
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
> http://hotjobs.sweepstakes.yahoo.com/signingbonus
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


Re: Validating Formatted Numbers Patch [Bugzilla 26151]

Posted by David Graham <gr...@yahoo.com>.
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 <ni...@blueyonder.co.uk> 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: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> 


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

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


Re: Validating Formatted Numbers Patch [Bugzilla 26151]

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
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: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


Re: Validating Formatted Numbers Patch [Bugzilla 26151]

Posted by Robert Leland <rl...@apache.org>.
Niall Pemberton wrote:

>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.
>
>http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26151
>
>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>
>  
>
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>


>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: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org