On Wed, Mar 28, 2001 at 12:11:37AM +1000, Jim Richards wrote:
> 
> >In Dec-2000 issue of Javaworld, there was an article by "Thor Kristmundsson"
> >about enhancing Struts framework with regex validation and automatic
> >properties. Though the article is outdated due to recent development in
> >Struts but I liked the idea and spent some time implementing it.
> 
> I'm not keen of using regex for the validation of form fields, as I find them too
> limiting. There are somethings you just can't do with regex that a general 
> bit of coding can handle (eg, credit card validation and good date checking).
> 
> 
> --
> Kumera - a new Open Source Content Management System
> for small to medium web sites written in Perl and using XML
> http://www.cyber4.org/kumera/index.html

I do think also, that - as somebody (sorry, I was lazy to search for the name)
mentioned a couple of monthes ago on the list - a java.text-like framework
/MessageFormat, DateFormat, NumberFormat et. al./ is what more appropriate
for a validation framework. In general you have a small grammar that controls
the input string parsing by some XxxxFormat class' parse method when it
tries to translate the input string into the Xxxx class according to a
format description given in the above mentioned small grammar. Also you'll
use the same format description when using XxxxFormat.format() to render
a string from an Xxxx type object. (You will need that when rendering
pages from business data.) Format descriptions can be cached, so
parsing occurs only once. This framework does not exclude using regular
expressions you can use them as one of the well defined grammars. But regexp
is really not enough. You can't validate even a date with it. Also,
you may need internationalization: the java.text framework was built
to cope with it, with regexp you are out of luck.

The other side of the coin is that no doubt this is much more complex
work then with regexps.                                        incze

Reply via email to