[Catalyst] State of the art in form validation; opinion poll… Model based forms/validation?

Ashley Pond V apv at sedition.com
Wed Dec 5 01:47:27 GMT 2007


I'm playing with CP::FormValidator::Simple and I like it all right  
but I feel like there must be something better than it and  
CP::FormValidator.

Putting the form profiles in YAML seems to work great (even though I  
hate the fairly ridiculous arrays of arrays grammar). For example:

In Controller:

$c->form($c->config->{form_profile}->{user});

In myapp.yml

form_profile:
   user:
     - last_name
     -
       - NOT_BLANK
       -
         - LENGTH
         - 1
         - 50
     - suffix
     -
       -
         - REGEX
         - !!perl/regexp '(?-xism:\A[IVX]{1,3}\z)'
     - email
     -
       - NOT_BLANK
       - EMAIL
       -
         - LENGTH
         - 6
         - 80

As crazy as it is, I like having it out of the code and into the  
config stuff.

I'm leaning more and more to having *all* of this stuff defined  
(validation patterns, user messages for invalid input, clues for CGI  
fields) in the Model (DBIC; I love it and never find time to try  
Rose). Sort of a super phat Model. If it's not defined exclusively  
there, it ends up defined there (via schema), the controller,  
possibly the templates (messages), and even client-side in JS. I know  
I'm showing my tremendous grasp of the obvious when I say, this is  
just effing awful.

What are best practices? DBIx::Class::Validation reusing your form  
package profiles? But you still have to write your own forms. I've  
searched around a lot and can't find a thorough, coherent Catalyst  
related doc about it.

I really want one, final approach to this I'll use every time from  
now on instead of experimenting with packages and home rolled stuff  
over and over. If someone is there, or even close. Please kick down.

As always, I appreciate everyone's time and expertise.

Thanks!
-Ashley




More information about the Catalyst mailing list