Laurent
Thank you for that information. I will certainly look at Data::Domain in some detail. I don't know if I will move over to it since I have already invested a lot of time and effort into using Data::FormValidator but I will certainly look at it for my next project. :)

Regards
Ian C. Docherty (Icydee)
Hi Ian,

I am currently looking at this issue for a big intranet application where we 
have many business rules to validate. As you say, rules interfere both with 
models and views,
and it would be nice to avoid duplicating the information. Now where should rules live ? Deriving rules from the database, as Carl suggested in this thread, is an excellent start, but it is not enough : there might be many things that a database cannot express, like regular expressions, contextual dependencies, or your example of date boundaries depending on the current date. On the other hand, form validation packages are often too much focused on the view and also fail to express the complex rules just mentioned.
The general problem is that the range of possible rules is very wide : some 
rules are quite simple, and for those we would like a short declarative 
language to express them, while other rules definitely need some computing 
power that goes beyond a declarative language.

So I tried to address this in Data::Domain, which was published on CPAN just 2 
weeks ago. This module is designed for providing a compact way to express 
complex constraints about structured data (including lazy constraints that may 
inspect the surrounding context). It then generates a structured set of error 
messages that can be fed to the view, either server-side through Template 
Toolkit, or client-side through Ajax methods. Messages are either 
auto-generated or can be redefined by client code (for example for 
internalization). The general scenario is that you get structured data by 
piping the parameters of your HTML form through CGI::Expand; then you validate 
the whole tree, and get back a tree of error messages that can be mapped back 
to the form fields.

You may also want to have a look at Declare::Constraints::Simple, which 
addresses the same problem and has some similarities in design.

Best regards, L. Dami


_______________________________________________
List: [email protected]
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to