Sending this again...as it seems to have got lost... Theres many reasons why url validation can fail - theres been a fair discussion on this list on just whether a slash is valid at the end of a url this week. Add to that allowing different configuration options for url validation somebody could believe they are typing in a valid url and get frustrated when all it tells them is "invalid url". Maybe that list I put up was over the top - perhaps just telling them which part is wrong would be better (i.e. scheme, authority, path, query or fragment - or the general format).
Adding an additional validate method to UrlValidator so that there is a choice of either getting a true/false or a more detailed code would be relatively straight forward and would provide a useful alternative - plugging it into struts so that there is either a single message or multiple messages is another thing. I must have missed a message because I see in this one Robert Leland asked the same thing. I can think of two approaches - either having one error message and several arguments, something like the following: <field ....> <arg name="url.format" key="url.format" position="0"/> <arg name="url.scheme" key="url.scheme" position="0"/> <arg name="url.authority" key="url.authority" position="0"/> <arg name="url.path" key="url.path" position="0"/> <arg name="url.query" key="url.query" position="0"/> <arg name="url.fragment" key="url.fragment" position="0"/> <field> or mutiple error messages: <field ....> <msg name="url.format" key="error.url.format"/> <msg name="url.scheme" key="error.url.scheme"/> <msg name="url.authority" key="error.url.authority" /> <msg name="url.path" key="error.url.path" /> <msg name="url.query" key="error.url.query" /> <msg name="url.fragment" key="error.url.fragment"/> <field> To get either of these to work would require slightly different mechanism to than that provided currently by the struts Resources class through getActionError(request, va field) but it wouldn't be a big deal to add an additional getActionError method. Anyway it probably should be a take it or leave it option - if your happy with a single message then fine, but have the option to allow url validation to be configured to output more specific information about the errror. What do you think, barking up the wrong tree, just plain barking or worth pursuing further? Niall ----- Original Message ----- From: "David Graham" <[EMAIL PROTECTED]> To: "Struts Developers List" <[EMAIL PROTECTED]> Sent: Friday, April 02, 2004 2:36 PM Subject: Re: Fw: UrlValidator() takes options - but how? > > --- Niall Pemberton <[EMAIL PROTECTED]> wrote: > > Sorry I jumped the gun and have put up a patch without agreeing the > > variable > > names - if its not acceptable I can always change it and re-submit the > > patch. > > > > I have used the three options you mention (except mine are currently all > > lower case) and a fourth which is "schemes" and it can ccontain a comma > > delimited list of valid schemes. > > > > That covers all the configurable options in UrlValidator. > > > > While I was testing this I did have another thought - UrlValidator just > > returns true or false when it validates and gives no indication of what > > bit > > of the validation failed. What do you think of changing it so it returns > > some kind of error code so that a more meaningful message could be > > returned > > to the user? > > > > Something like > > > > Code Condition > > 0 valid > > 101 Invalid Characters > > 102 Invalid Structure > > > > 201 Invalid Scheme Format > > 202 Invalid Scheme Value (show valid scheme values) > > > > 301 Invalid Authority Format > > 302 Invalid Authority IP Address > > 303 Invalid Authority Host Name > > 304 Invalid Authority - not IP Address or Hostname > > 305 Invalid Port > > > > 401 Invalid Path Format > > 402 Invalid Path - ends with / > > 403 Invalid Path - two slashes not allowed > > 404 Invalid Path - slashes/dots > > > > 501 Invalid Query format > > > > 601 Fragment Not Allowed > > How useful is this feature? As a user, I don't care about RFCs or URL > validation rules; I just want to know whether I mistyped a URL. > > David > > > > > > > The only thing is how to configure validator to output 16 different > > messages? > > > > > > ----- Original Message ----- > > From: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > > To: "Struts Developers List" <[EMAIL PROTECTED]> > > Sent: Friday, April 02, 2004 3:01 AM > > Subject: Re: Fw: UrlValidator() takes options - but how? > > > > > > > > I was thinking of openning a bugzilla and sticking a patch up - but > > I > > don't > > > > want > > > > to steal your thunder if you'd rather do it. > > > > > > I would encourage a bugzilla ticket, it sounds like there is almost > > > agreement on the needed changes, and options. Before fileing do try to > > firm > > > up those options. Since the commons validator already has the > > > allow2slashes,noFragments and allowAllSchemes. These would be a good > > start. > > > > > > > > > > > > > > > > > Niall > > > > > > > > > > > > > > Adam > > > > > > > > > > On 04/01/2004 10:08 PM Niall Pemberton wrote: > > > > > > Adam Hardy suggested "allow2slashes", "nofragments" and > > > > "allowallschemes" > > > > > > being either true/false > > > > > > > > > > > > I think rather than having "allowallschemes", have a "schemes" > > parameter > > > > > > which can be either "all" (which sets the allow all schemes > > option) > > or a > > > > > > comma delimited list of valid schemes. > > > > > > > > > > > > Alternatively you could have Adam's suggestion plus any <var> > > that > > > > starts > > > > > > with "scheme" is taken to build an array of schemes. Something > > like: > > > > > > > > > > > > <field property="someUrl" depends="myUrlValidator"> > > > > > > <var><var-name>allow2slashes</var-name> > > > > > > <var-value>true</var-value> > > > > > > </var> > > > > > > <var><var-name>nofragments</var-name> > > > > > > <var-value>true</var-value> > > > > > > </var> > > > > > > <var><var-name>allowallschemes</var-name> > > > > > > <var-value>false</var-value> > > > > > > </var> > > > > > > <var><var-name>scheme1</var-name> > > > > > > <var-value>http</var-value> > > > > > > </var> > > > > > > <var><var-name>scheme2</var-name> > > > > > > <var-value>ftp</var-value> > > > > > > </var> > > > > > > <var><var-name>scheme3</var-name> > > > > > > <var-value>telnet</var-value> > > > > > > </var> > > > > > > </field> > > > > > > > > > > > > > > > > > > Niall > > > > > > > > > > > > ----- Original Message ----- > > > > > > From: "David Graham" <[EMAIL PROTECTED]> > > > > > > To: "Struts Developers List" <[EMAIL PROTECTED]> > > > > > > Sent: Thursday, April 01, 2004 8:17 PM > > > > > > Subject: Re: Fw: UrlValidator() takes options - but how? > > > > > > > > > > > > > > > > > > > > > > > >>--- Niall Pemberton <[EMAIL PROTECTED]> wrote: > > > > > >> > > > > > >>>Sorry this went to the wrong list, but anyway.... > > > > > >>> > > > > > >>>Looking at CVS there is a validateUrl() method in the Struts > > > > FieldChecks > > > > > >>>class (added in version 1.15) - problem is it uses commons > > > > > >>>GenericValidator > > > > > >>>which has a static instance. > > > > > >>> > > > > > >>>What do you think about changing this to instantiate a > > UrlValidator > > if > > > > > >>>any > > > > > >>>configuration parameters have been enetered in validation.xml, > > > > otherwise > > > > > >>>use > > > > > >>>the GenericValidator? > > > > > >> > > > > > >>Sounds ok to me but we need to define the variable names the > > method > > > > > >>recognizes and will use in UrlValidator configuration. > > > > > >> > > > > > >>David > > > > > > > > > > -- > > > > > struts 1.2 + tomcat 5.0.19 + java 1.4.2 > > > > > Linux 2.4.20 Debian > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > 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] > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > __________________________________ > Do you Yahoo!? > Yahoo! Small Business $15K Web Design Giveaway > http://promotions.yahoo.com/design_giveaway/ > > --------------------------------------------------------------------- > 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]