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

2007-05-17 Thread Matt S Trout
On Wed, May 16, 2007 at 06:46:57PM -0700, mla wrote: I'm thinking Catalyst::Model should provide some sort of interface for this. This doesn't belong at the Catalyst core level since Catalyst is expressly -not- opinionated about how your model is written. If there was a consistent interface

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

2007-05-17 Thread mla
Matt S Trout wrote: On Wed, May 16, 2007 at 06:46:57PM -0700, mla wrote: I'm thinking Catalyst::Model should provide some sort of interface for this. This doesn't belong at the Catalyst core level since Catalyst is expressly -not- opinionated about how your model is written. If there was a

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

2007-05-17 Thread Matt S Trout
On Thu, May 17, 2007 at 02:36:54PM -0700, mla wrote: Matt S Trout wrote: On Wed, May 16, 2007 at 06:46:57PM -0700, mla wrote: I'm thinking Catalyst::Model should provide some sort of interface for this. This doesn't belong at the Catalyst core level since Catalyst is expressly -not-

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

2007-05-16 Thread Jason Gottshall
Chris Laco wrote: Off Topic. Making a note for myself and DBIC::Validation 100 can be validated because we have %colinfo {size = 100} Patterns could be covered in validation_profiles at the source level...but maybe this would be nice as well: { type = 'VARCHAR', size = 100,

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

2007-05-16 Thread John Napiorkowski
--- Jason Gottshall [EMAIL PROTECTED] wrote: Chris Laco wrote: Off Topic. Making a note for myself and DBIC::Validation 100 can be validated because we have %colinfo {size = 100} Patterns could be covered in validation_profiles at the source level...but maybe this would be nice as

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

2007-05-16 Thread mla
Jason Gottshall wrote: This gets at precisely the issue I've been wrestling with lately. Validation constraints at all levels (db, model, controller, form, etc.) seem to sort themselves into two general categories: field-specific questions (Is it required/unique?, Does it match a given pattern?,

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

2007-05-15 Thread Perrin Harkins
On 5/14/07, Dave Rolsky [EMAIL PROTECTED] wrote: eval { $user-update( %bunch_of_stuff ); }; if ( my $e = Exception::Class-caught( 'My::App::Exception::DataValidation') ) { # $e-errors contains multiple data validation error messages # stuff them in the session

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

2007-05-15 Thread mla
Perrin Harkins wrote: On 5/14/07, Dave Rolsky [EMAIL PROTECTED] wrote: eval { $user-update( %bunch_of_stuff ); }; if ( my $e = Exception::Class-caught( 'My::App::Exception::DataValidation') ) { # $e-errors contains multiple data validation error messages # stuff

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

2007-05-15 Thread Christopher H. Laco
where do you handle the validation? Only in the controller or in both the model and controller? Fail Early. Fail Often. Some will say redundancy sucks. I agree, except for where validation is concerned. If you're writing data from the web into a model, check the data at the page level, and at

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

2007-05-15 Thread Bill Moseley
On Tue, May 15, 2007 at 11:42:52AM -0700, mla wrote: And where do you handle the validation? Only in the controller or in both the model and controller? Controller only in my case. There could be extra validation in the ORM, and of course in the database. Could you give a short example of

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

2007-05-15 Thread Perrin Harkins
On 5/15/07, mla [EMAIL PROTECTED] wrote: And where do you handle the validation? Only in the controller or in both the model and controller? In the form processing code. This system has a CMS where users get to generate forms and decide which fields will be on specific forms, so the required

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

2007-05-15 Thread Matt S Trout
On Tue, May 15, 2007 at 02:51:18PM -0400, Christopher H. Laco wrote: where do you handle the validation? Only in the controller or in both the model and controller? Fail Early. Fail Often. Some will say redundancy sucks. I agree, except for where validation is concerned. If you're

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

2007-05-15 Thread Peter Karman
mla scribbled on 05/15/07 13:42: Perrin Harkins wrote: And where do you handle the validation? Only in the controller or in both the model and controller? Could you give a short example of taking an actual field from the request parameters, validating it, and updating a row with it?

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

2007-05-15 Thread mla
Matt S Trout wrote: On Tue, May 15, 2007 at 02:51:18PM -0400, Christopher H. Laco wrote: where do you handle the validation? Only in the controller or in both the model and controller? Fail Early. Fail Often. Some will say redundancy sucks. I agree, except for where validation is concerned.

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

2007-05-15 Thread Christopher H. Laco
mla wrote: Matt S Trout wrote: On Tue, May 15, 2007 at 02:51:18PM -0400, Christopher H. Laco wrote: where do you handle the validation? Only in the controller or in both the model and controller? Fail Early. Fail Often. Some will say redundancy sucks. I agree, except for where validation =

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

2007-05-15 Thread Christopher H. Laco
Christopher H. Laco wrote: mla wrote: Matt S Trout wrote: On Tue, May 15, 2007 at 02:51:18PM -0400, Christopher H. Laco wrote: where do you handle the validation? Only in the controller or in both the model and controller? Fail Early. Fail Often. Some will say redundancy sucks. I agree,

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

2007-05-15 Thread mla
Christopher H. Laco wrote: Damned if you do... damned if you don't. There is no one correct answer. So true ;-| In terms of form validation, what do you guys think of this interface? It uses perl to handle conditional logic/dependencies instead of using a spec language like

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

2007-05-15 Thread Bill Moseley
On Tue, May 15, 2007 at 02:08:45PM -0700, mla wrote: In terms of form validation, what do you guys think of this interface? It uses perl to handle conditional logic/dependencies instead of using a spec language like Data::FormValidator. Might look at Rose::HTML::Objects and Form::Processor

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

2007-05-15 Thread Matt S Trout
On Tue, May 15, 2007 at 01:04:42PM -0700, mla wrote: Okay, thanks very much for this. So in terms of the model constraints, you will validate everything twice. Once at the controller layer (where it leverages info from the model), and once in the model itself. So you can interrogate the

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

2007-05-15 Thread mla
Matt S Trout wrote: On Tue, May 15, 2007 at 01:04:42PM -0700, mla wrote: Okay, thanks very much for this. So in terms of the model constraints, you will validate everything twice. Once at the controller layer (where it leverages info from the model), and once in the model itself. So you can

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

2007-05-14 Thread mla
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

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

2007-05-14 Thread Wade . Stuart
mla [EMAIL PROTECTED] 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

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

2007-05-14 Thread mla
[EMAIL PROTECTED] wrote: mla [EMAIL PROTECTED] 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

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

2007-05-14 Thread RA Jones
mla wrote: Clearly Catalyst has an opinion on how to handle the request with Catalyst::Request. I'm sure you could override that somehow and use your own, but it's helpful that there's a default request interface that new developers can get up to speed quickly with. I don't see why that can't

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

2007-05-14 Thread Dave Rolsky
On Mon, 14 May 2007, mla wrote: Anyone have validation logic in the model and are happy with it? There are two kinds of validation here. One is model-level validation, and yes, it's in my model code. My model throws exceptions, which I trap in the controller and mess with to make it work

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

2007-05-14 Thread mla
Dave Rolsky wrote: On Mon, 14 May 2007, mla wrote: Anyone have validation logic in the model and are happy with it? There are two kinds of validation here. One is model-level validation, and yes, it's in my model code. My model throws exceptions, which I trap in the controller and mess

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

2007-05-14 Thread Dave Rolsky
On Mon, 14 May 2007, mla wrote: There are two kinds of validation here. One is model-level validation, and yes, it's in my model code. My model throws exceptions, which I trap in the controller and mess with to make it work for the web UI. The controller might also do some validation, but

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

2007-05-14 Thread mla
Dave Rolsky wrote: On Mon, 14 May 2007, mla wrote: Could you give an example of how you munge the exceptions into error messages for the user? eval { $user-update( %bunch_of_stuff ); }; if ( my $e = Exception::Class-caught( 'My::App::Exception::DataValidation') ) { #

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

2007-05-14 Thread Bill Moseley
On Mon, May 14, 2007 at 04:44:41PM -0500, Dave Rolsky wrote: On Mon, 14 May 2007, mla wrote: Anyone have validation logic in the model and are happy with it? There are two kinds of validation here. One is model-level validation, and yes, it's in my model code. My model throws exceptions,

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

2007-05-14 Thread Dave Rolsky
On Mon, 14 May 2007, Bill Moseley wrote: There are two kinds of validation here. One is model-level validation, and yes, it's in my model code. My model throws exceptions, which I trap in the controller and mess with to make it work for the web UI. I tend to have much less validation in the

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

2007-05-14 Thread mla
Bill Moseley wrote: On Mon, May 14, 2007 at 04:44:41PM -0500, Dave Rolsky wrote: On Mon, 14 May 2007, mla wrote: Anyone have validation logic in the model and are happy with it? There are two kinds of validation here. One is model-level validation, and yes, it's in my model code. My model

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

2007-05-14 Thread Bill Moseley
On Mon, May 14, 2007 at 07:42:00PM -0700, mla wrote: Which is why I like the form validation tools to not be specific to the web/HTML side of things. The HTML side of the forms are easy, anyway, and often require hand-customizing. That way the same forms can be used for more than just the