[<<] Industrie Toulouse

Writing about ASP.NET, whyTHEluckySTIFF writes:

Validation controls are way too simplistic. What if I want to validate a control based on the condition of another control? On many forms, I want to ignore some fields based on the state of a checkbox. This should be easy. I've built some complex validation controls and I hope to put them up here sometime to soothe other developer's frustrations. I imagine this is a common complaint.
Ohhhhh. Yes it is. I'm sure it's a very common complaint. I'm not using ASP.NET, but a godsend in my life for Zope has been Formulator. I'm now in the habit of defining my forms on disks in Zope products (just using regular Python code - not the Formulator XML syntax), and in the last couple of days have had some tremendous experiences with it. Inspired by Zope 3's schema capabilities (which is what Formulator morphed into when it became part of Zope 3), I'm using my forms as so much more than just display data. They've become an interface definition of sorts (which is exactly how they're used in Zope 3). I rely on them to prepare data before sending it off to a database. And there's this wonderful validation thing.

And let's face it - simple form validation is better than none. We've been using Formulator for quite some time on the public side of our sites. Where we've avoided using it is in the administration screens. Normally, we keep these to ourselves and they're not terribly glamourous. But as we're turning more products over to customers, validation's become increasingly important. Now that a form definition is being used to prep data for the database, it's become exceedingly important.

But now that the simple validation is out of the way, what now? I have a situation where I have multiple date/time fields. I need to put in some rules that say "The off sale date can't be earlier than the on-sale date" or "the show date can't be earlier than the display date". It's easy to process this stuff brute force, but it would be nice to tie it in to the core validation framework. Pulling rabbits out of my ass here, I'd imagine a way to add extra validators onto Formulator - objects that contain some sort of validation code that effects multiple fields, and has a way of highlighting which fields are in error. But... Well, there are all sorts of ramifications of this that might change how the validation errors are or can be reported. I do know that I can probably make something work for my own system. Hmmm...