You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Martin Cooper <ma...@apache.org> on 2004/09/12 22:41:37 UTC

Bug in Struts Validator

There appears to be a bug in the way that the error messages are put 
together in the validator code. The problem shows up in both the server 
side and client side messages, and I suspect appears only for messages 
that have more than one argument.

The easiest way to see the problem is in the registration tests in the 
validator module of the struts-examples app. If you just stick an "a" in 
every field and click Save, you'll see:

o 5 can not be less than null characters.
o Zip is invalid.
o Phone is invalid.
o E-mail is an invalid e-mail address.

The first of these is clearly wrong, and should have read "First Name can 
not be less than 5 characters". Somehow the field name seems to have been 
missed from the args.

I've taken a quick look at the code, and don't see where things are going 
wrong, so I'm hoping someone more familiar with that code could take a 
quick look also, and see if they can spot the problem.

--
Martin Cooper


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


Re: Bug in Struts Validator

Posted by David Graham <gr...@yahoo.com>.
--- Martin Cooper <mf...@gmail.com> wrote:
<snip>

> I just figured out the same thing. ;-} While I think this is OK for
> now, I really think this is a Validator bug. You shouldn't have to
> specify the position explicitly; it would be perfectly logical for the
> lack of the 'position' attribute to mean 'next'. That's certainly what
> I would have expected, anyway.

Sorry about that.  When I made this change I updated all the validator's
example xml but forgot to update Struts.  The position attribute defaults
to 0 so technically you shouldn't have to specify it for the first arg.

Martin, that's a good suggestion about not specifying the position.  I
don't consider it a bug but I'll enter an enhancement ticket so we don't
forget.

David


> 
> Oh well. Thanks for fixing it, Joe.
> 
> --
> Martin Cooper
> 
> 
> > 
> > So whenever the XML was adjusted to use <arg> instead of <arg0>,
> > <arg1>, etc, it looks like that step was just overlooked.
> > 
> > I think I fixed it in all the relevant places: min length for first
> > name, max length for last name, and the int and float ranges on the
> > type validation form.  Hopefully I didn't miss any!
> > 
> > Joe
> > 
> > --
> > Joe Germuska
> > Joe@Germuska.com
> > http://blog.germuska.com
> > "In fact, when I die, if I don't hear 'A Love Supreme,' I'll turn
> > back; I'll know I'm in the wrong place."
> >    - Carlos Santana
> > 
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> > For additional commands, e-mail: dev-help@struts.apache.org
> > 
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: Bug in Struts Validator

Posted by Martin Cooper <mf...@gmail.com>.
On Sun, 12 Sep 2004 18:45:31 -0500, Joe Germuska <jo...@germuska.com> wrote:
> At 1:41 PM -0700 9/12/04, Martin Cooper wrote:
> >There appears to be a bug in the way that the error messages are put
> >together in the validator code. The problem shows up in both the
> >server side and client side messages, and I suspect appears only for
> >messages that have more than one argument.
> >
> >The easiest way to see the problem is in the registration tests in
> >the validator module of the struts-examples app. If you just stick
> >an "a" in every field and click Save, you'll see:
> >
> >o 5 can not be less than null characters.
> >o Zip is invalid.
> >o Phone is invalid.
> >o E-mail is an invalid e-mail address.
> >
> >The first of these is clearly wrong, and should have read "First
> >Name can not be less than 5 characters". Somehow the field name
> >seems to have been missed from the args.
> >
> >I've taken a quick look at the code, and don't see where things are
> >going wrong, so I'm hoping someone more familiar with that code
> >could take a quick look also, and see if they can spot the problem.
> 
> The bug is in the XML, not in the code.  When using the <arg>
> element, one should use the "position" attribute to specify where in
> the arg array the specific argument belongs.  (So I've just
> discovered.)

I just figured out the same thing. ;-} While I think this is OK for
now, I really think this is a Validator bug. You shouldn't have to
specify the position explicitly; it would be perfectly logical for the
lack of the 'position' attribute to mean 'next'. That's certainly what
I would have expected, anyway.

Oh well. Thanks for fixing it, Joe.

--
Martin Cooper


> 
> So whenever the XML was adjusted to use <arg> instead of <arg0>,
> <arg1>, etc, it looks like that step was just overlooked.
> 
> I think I fixed it in all the relevant places: min length for first
> name, max length for last name, and the int and float ranges on the
> type validation form.  Hopefully I didn't miss any!
> 
> Joe
> 
> --
> Joe Germuska
> Joe@Germuska.com
> http://blog.germuska.com
> "In fact, when I die, if I don't hear 'A Love Supreme,' I'll turn
> back; I'll know I'm in the wrong place."
>    - Carlos Santana
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
> 
>

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


Re: Bug in Struts Validator

Posted by Joe Germuska <Jo...@Germuska.com>.
At 1:41 PM -0700 9/12/04, Martin Cooper wrote:
>There appears to be a bug in the way that the error messages are put 
>together in the validator code. The problem shows up in both the 
>server side and client side messages, and I suspect appears only for 
>messages that have more than one argument.
>
>The easiest way to see the problem is in the registration tests in 
>the validator module of the struts-examples app. If you just stick 
>an "a" in every field and click Save, you'll see:
>
>o 5 can not be less than null characters.
>o Zip is invalid.
>o Phone is invalid.
>o E-mail is an invalid e-mail address.
>
>The first of these is clearly wrong, and should have read "First 
>Name can not be less than 5 characters". Somehow the field name 
>seems to have been missed from the args.
>
>I've taken a quick look at the code, and don't see where things are 
>going wrong, so I'm hoping someone more familiar with that code 
>could take a quick look also, and see if they can spot the problem.

The bug is in the XML, not in the code.  When using the <arg> 
element, one should use the "position" attribute to specify where in 
the arg array the specific argument belongs.  (So I've just 
discovered.)

So whenever the XML was adjusted to use <arg> instead of <arg0>, 
<arg1>, etc, it looks like that step was just overlooked.

I think I fixed it in all the relevant places: min length for first 
name, max length for last name, and the int and float ranges on the 
type validation form.  Hopefully I didn't miss any!

Joe

-- 
Joe Germuska            
Joe@Germuska.com  
http://blog.germuska.com    
"In fact, when I die, if I don't hear 'A Love Supreme,' I'll turn 
back; I'll know I'm in the wrong place."
    - Carlos Santana

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