You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Eddie Bush <ek...@swbell.net> on 2002/07/26 05:10:55 UTC
Validator Woes :-/
Ok - I see no reason for this. I had validator humming along just fine
and happy as you please, and then I added one more mask requirement and
it blew up in my face ... only it didn't say it did. "What is he going
on about?!", you may ask. "Does he have a point - something
objective?", you may ask. Yes, I do!
I have a DynaValidatorForm with ... several properties. I was trying to
work my way into figuring out these danged non-standard, MS regexps ...
and when I was working on adding one for state (two-letter code), I just
... well when it's there it passes validation with absolute crap in all
of the fields. The constant "whydoifail" is the regexp in question.
Could someone please take a look and tell me if I just have my head
stuck where the sun don't shine or what? The constant was initially
named "state" - but I thought perhaps that was a bad move when it didn't
work ... and have renamed it a few choice things while I worked on it -
name varying with my mood and perturbedness. I cleaned it up
substantially for posting to the list ;-)
Thank you for any insight!
Eddie
Here's my validation.xml
<form-validation>
<global>
<constant>
<constant-name>name</constant-name>
<constant-value>^[A-Z][A-Za-z]*$</constant-value>
</constant>
<constant>
<constant-name>phone</constant-name>
<constant-value>^\(?(\d{3})\)?[-| ]?(\d{3})[-|
]?(\d{4})$</constant-value>
</constant>
<constant>
<constant-name>zip</constant-name>
<constant-value>^\d{5}$</constant-value>
</constant>
<constant>
<constant-name>whydoifail</constant-name>
<constant-value>^[A-Z]{2}$</constant-value>
</constant>
</global>
<formset>
<form name='loginForm'>
<field property='firstName' depends='required,mask'>
<arg0 key='loginForm.firstName.label'/>
<msg name="mask" key="errors.mask.name"/>
<var>
<var-name>mask</var-name>
<var-value>${name}</var-value>
</var>
</field>
<field property='lastName' depends='required,mask'>
<arg0 key='loginForm.lastName.label'/>
<msg name="mask" key="errors.mask.name"/>
<var>
<var-name>mask</var-name>
<var-value>${name}</var-value>
</var>
</field>
<field property='address1' depends='required'>
<arg0 key='loginForm.address1.label'/>
</field>
<field property='address2' depends='required'>
<arg0 key='loginForm.address2.label'/>
</field>
<field property='city' depends='required'>
<arg0 key='loginForm.city.label'/>
</field>
<field property='state' depends='required,mask'>
<arg0 key='loginForm.state.label'/>
<msg name="mask" key="errors.mask.state"/>
<var>
<var-name>mask</var-name>
<var-value>${whydoifail}</var-value>
</var>
</field>
<field property='zip' depends='required,mask'>
<arg0 key='loginForm.zip.label'/>
<msg name="mask" key="errors.mask.zip"/>
<var>
<var-name>mask</var-name>
<var-value>${zip}</var-value>
</var>
</field>
<field property='email' depends='required'>
<arg0 key='loginForm.email.label'/>
</field>
</form>
</formset>
</form-validation>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Validator Woes :-/
Posted by Eddie Bush <ek...@swbell.net>.
Good idea! I hadn't thought of that! <smack-head/>
Jonathan Fuerth wrote:
>On Thu, Jul 25, 2002 at 11:01:42PM -0500, Eddie Bush wrote:
>
>>If you do need to do that, you might try escaping them -
>>ie. errors.mask.state={0} must be a two-letter state abbreviation.
>>(Ex. \"AZ\")
>>
>>I bet that would work - of course, if you wanted to use it somewhere
>>else you might not get the output you wanted.
>>
>
>The best bet would be to use the HTML-defined entity " since it
>would work everywhere in an HTML document. As an added bonus, it will
>even work in the new Swing GUI components that support HTML labels. :)
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Validator Woes :-/
Posted by Jonathan Fuerth <fu...@sqlpower.ca>.
On Thu, Jul 25, 2002 at 11:01:42PM -0500, Eddie Bush wrote:
> If you do need to do that, you might try escaping them -
> ie. errors.mask.state={0} must be a two-letter state abbreviation.
> (Ex. \"AZ\")
>
> I bet that would work - of course, if you wanted to use it somewhere
> else you might not get the output you wanted.
The best bet would be to use the HTML-defined entity " since it
would work everywhere in an HTML document. As an added bonus, it will
even work in the new Swing GUI components that support HTML labels. :)
--
Jonathan Fuerth - SQL Power Group Inc.
(416)218-5551 (Toronto); 1-866-SQL-POWR (Toll-Free)
Unleash the Power of your Corporate Data - http://www.sqlpower.ca/
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Validator Woes :-/
Posted by Eddie Bush <ek...@swbell.net>.
Why is it, every time I post to this list, I turn around and immediately
discover the answer? The value for the key 'errors.mask.state' had two
double-quotes in it to set off an example. Of course, I'm sure if I'd
looked I'd have noticed I had JS errors. No - that didn't even occur to
me. Everything works just FINE.
Short story: Don't use double-quotes in your resource strings if you
intend to use those keys in validator.
If you do need to do that, you might try escaping them - ie.
errors.mask.state={0} must be a two-letter state abbreviation. (Ex. \"AZ\")
I bet that would work - of course, if you wanted to use it somewhere
else you might not get the output you wanted.
Sorry to bother!
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>