James.Q.L wrote:

> i am wondering how are other people using DFV and i would like to adopt a 
> simpler and
> maintaintable way..

I usually have a custom method that I pass as the value for 'msgs' that creates
a hash of error flags for me. These flags are the name of the field (or the name
of the constraint if a field has multiple constraints) prefixed by 'err_'. Then
if it's missing another flag is prefixed by 'missing_' and if it's invalid yet
another flag is prefixed with 'invalid_'.

You can see an example of this method in smolder:
http://smolder.svn.sourceforge.net/viewvc/smolder/trunk/lib/Smolder/Control.pm?view=markup
starting at line 345.

Then depending on the project I either put the error messages into the template
(this is what smolder does) and then show the right ones based on the error
flags present. Or if my needs are more complicated (messages can change more
often or need to be translated into multiple languages, etc) then I put the
messages in a config file (Krang does this) where the message's name matches the
'missing_' and 'invalid_' error flags.

Whatever I do, I never hard code the error messages into the Perl code.

-- 
Michael Peters
Developer
Plus Three, LP


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[email protected]/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to