[Catalyst] Where should constraints go

Ian Docherty ian at iandocherty.com
Fri Nov 3 18:54:44 GMT 2006


Brian Kirkbride wrote:
...
> This is the approach I have taken in the past, although I hadn't 
> included any metadata (ie [1,16]) with the error_id.  This fits into 
> separation of business and presentation logic nicely because the model 
> is free to return an error that has some semantic meaning 
> "PASSWORD_TOO_SHORT", but the view is free to say "Enter a longer 
> password you submoron, you!" if need be.
>
> For my Catalyst apps, I can either do something like:
>
>     [% c.format_error(error_id) %]
>
> or
>
>     [% error_messages.$error_id %]
>
> or even
>
>     [% error_messages.${lang}.${error_id} %]
>
> to map the model-specified error to a presentable string for the 
> view.  I prefer the first, but it does clutter the Application Context 
> namespace somewhat.
>
> Best,
> Brian Kirkbride

This is pretty much what I do via the FormValidator. I convert the 
'missing' or the 'invalid' messages that it produces into the flags

[% missing.user_username %]
and
[% invalid.user_username.length %]
which then result in the error messages being produced.

I still need to give some thought to internationalisation, but that is 
another question. :)



More information about the Catalyst mailing list