[Catalyst] Where should constraints go

Ian Docherty ian at iandocherty.com
Fri Nov 3 15:33:16 GMT 2006


Carl Franks wrote:
>
> I made on very basic start [1] on being able to automatically create
> constraints from the database column types. At the moment it only
> supports mysql, and it's also probably very out-of-sync with the
> current svn trunk - but I'd /really/ like to see it finished, and I
> /really/ don't have any time to work on it, so if you want to take a
> look and do something with it, that'd be great.
> My primary goal was to get it working with HTML::Widget as
> H-W-Constraint-DBIC [2], but there's no reason it couldn't be
> integrated with any other validation package.
>
> [1] 
> http://dev.catalyst.perl.org/repos/bast/branches/DBIx-Class/columns_info_for 
>
> [2] 
> http://dev.catalystframework.org/repos/Catalyst/trunk/HTML-Widget-Constraint-DBIC/ 
>
>
> Carl
Carl
Creating the constraints is not really the problem. Your approach 
certainly helps and one that any ORM should include. I can see that it 
would take a fair amount of work to cover all bases. For example, if a 
constraint was put on a DATE field such that it could not be later than 
NOW and no earlier than NOW - 20 Days. (for example).

Putting these sort of constraints is the duty of either the database 
level (where they naturally go anyway) or perhaps in the business logic 
layer.

My problem is finding a clean way of getting these constraints out of 
the Model and into the View so that I can generate meaningful error 
messages without hard-coding them in the templates. By 'clean' I mean 
not having to code the Controller to act as the middle-man and just pass 
them from the Model to the View.

Perhaps I am expecting too much.




More information about the Catalyst mailing list