[Catalyst] Form validation in insert() and update()?

Wade.Stuart at fallon.com Wade.Stuart at fallon.com
Mon May 14 21:14:37 GMT 2007








mla <maurice.aubrey at gmail.com> wrote on 05/14/2007 02:45:49 PM:

> I'm studying different frameworks for a new project.
> I'm very new to Catalyst and am reading through the tutorial.
> In part 8, advanced CRUD, there's an example of form validation.
>
> The approach is very similar to what I've always used
> but I've been looking at Rails recently and noticed that they
> run the validation code at the point the ORM is saved/updated.
>
> What are the thoughts on this? It does seem kind of elegant to
> not have the validation tied to a specific html form. That *any*
> attempt to modify an ORM object would, regardless of source,
> hit the same validation checks and produce the same errors.


It gets hard.  The validation state depends on the controller more than you
would think.  My old projects pushed the validation from my Model,  the
problem is that while some data may be technically valid for the database
tables,  depending on the controller's use and intent it may not be valid
for that state.  I have since started to tie the Validation in the
Controller files and it seems to be saving me a lot of bouncing while
editing.

>
> The other thing that's striking about the Rails approach to me
> is the convention over configuration philosophy. I really like the
> fact that Catalyst isn't tied to a specific view or ORM approach.
> But OTOH, it makes the framework a bit daunting and seem less
> organized.


Some people like townhouses, some people like to architect their own house.
Catalyst is as simple or complex as you make it.  We have normality. I
repeat, we have normality.
Anything you still can't cope with is therefore your own problem.




> How do you build/validate forms? Well, you use HTML::Widget or
> Data::Validate or Catalyst::Enyzme or FormFu. <quietly sobbing>
>



Any of the above.


> I would like to see The Way defined, with copious footers about
> TMTOWTDI. I'm a huge fan of Perl and use it for my day job, so
> I'm not being critical of The Perl Way... just that there is
> something to be said about having a well defined "default way,"
> with officially blessed modules that aren't likely to be
> abandoned in six months.





You are not in the airport -- there are no people movers here.


>
> So what are the modules of choice right now? DBIx::Class for
> the ORM. TT for the view. Data::Validate for form validation?
> Any agreement on how/where to create the forms themselves?
>


I think the agreement is use whatever you are most productive with -- try a
few of them out.  Most exist because the authors had touble with the way
another one worked and decided her way was better,  the outcome is more
choice;  fewer chains.






More information about the Catalyst mailing list