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

Christopher Laco claco at chrislaco.com
Wed Dec 5 02:00:34 GMT 2007


Ashley Pond V wrote:
> 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.
> =


Take a look at Mango::Form. I sort of wanted that too. The profile,
messages, and validation rules are all in yaml config files in a merged
format.

I've tinkered with stuffing all of that somewhere in DBIC schemas... but
in my case, I need to use it even when I'm not using DBIC...

> 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

I have form solutions. We all write our own because they all suck in
there own special ways. IMHO, forms are one of those things in which
there will never be a solution that is flexible enough and still be usable.

YMMV.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 249 bytes
Desc: OpenPGP digital signature
Url : http://lists.scsys.co.uk/pipermail/catalyst/attachments/20071204/fdfb=
5508/signature.pgp


More information about the Catalyst mailing list