Why don't you just write your own validator plugin? Then you'll have total control over what variables you include in your validation.xml and how your validator uses them. This would take about 15 minutes once you know how to do it. For an example, you can search the Web for Matt Raible's "Validate Two Fields" article. If you can't find it, I wrote several validator extensions for Struts 1.1, including some date-related ones (one I recall was a date range limiter). I could send you an example (later). You'll have to modify slightly to adapt for Struts 1.2. Not sure if there is an example in the Struts docs or the wiki.
Erik -----Original Message----- From: Thai Dang Vu <[EMAIL PROTECTED]> Sent: Aug 15, 2005 1:58 PM To: user@struts.apache.org Subject: Re: How to specify more than 1 datePattern in date validation? You're right. RE is not suitable in this case. If we don't specify a pattern, Struts will use SimpleDateFormat's default which is MM/dd/yyyy (I've just read about it in the Struts In Action book from somebody here last week, so I'm not sure if that pattern is the default). One thing I'm sure of is that Struts will not try more than one date format rule. >>> [EMAIL PROTECTED] 8/15/2005 1:41:02 PM >>> Thai Dang Vu wrote: > If I want to validate a date field, I will put something like this in the > validation.xml file > > <field property="myDate" depends="date"> > <arg0 key="Date field" resource="false"/> > <var> > <var-name>datePattern</var-name> > <var-value>MM/dd/yyyy</var-value> > </var> > </field> > > So, if I want to enable 2 ways of entering a date (MM/dd/yyy and MM-dd-yyyy), > how should I write in the validation.xml file? The only two possibilities I can think of are to use the match validation with a suitable regular expression, which will allow you to make sure the date string is in the right format but can't easily check that it's really a legal date, or write your own custom validation rule. The date validation doesn't provide for specifying multiple patterns. Actually, one other possibility: if you don't specify a pattern, Validator will use SimpleDateFormat's default short date format rules, which might be more flexible than you can express with a pattern; check the documentation for SimpleDateFormat to see if that would meet your needs. L. -- Laurie Harper Open Source advocate, Java geek: http://www.holoweb.net/laurie Founder, Zotech Software: http://www.zotechsoftware.com/ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]