Re: [FE-discuss] Getting the message key?

Top Page
Author: Andreas Klostermann
Date:  
To: formencode-discuss
Subject: Re: [FE-discuss] Getting the message key?

> So while I'm really appreciating your feedback, I'm looking for a general
> approach to solve that problem ("how to detect the error cause after
> validation), especially because I think (hope?) this is not a very special
> situation but very common one.
>
> If you think about it, it's essentially more important stating the cause of
> the error than the actual error message. If the problem is reduced to the
> max, one could decide not to return any kind of error message but just the
> error cause so that the developer can use his own error messages.


I still think you should subclass the existing validators and create
your own. May be you misunderstood the principle behind formencode. A
validotor is a rule, *not* a set of rules. If it checks multiple fields,
then it is still only one rule: "Each is valid" or "field a matches
field b". Maybe you should adjust the granularity of your validators.

Formencode's email validator for example, is a bad example for this. It
creates different error messages for a few cases. While you should not
use this validator in your own projects, because it accepts a few cases
of clearly invalid email adresses, it validates more than one rule about
the email. It could have been realized by chained validators, like
"there's a @", "domain name too short", "domain name too long", "invalid
characters in user name" etc.

There are a few other examples... try to validate "None" with a
OneOf(["Hello", "World"]) validator. It just doesn't complain. Or try
Range(min=1, max=2) as suggested by the web site docs (0.4). 0.7 does
accept the params, but doesn't use them...

And don't let the fear of "coupling" drive you into a writer's block of
some sort. It's nice to think about API design, but it's really bad if
it stops you dead.

Greetings,
Andreas


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
FormEncode-discuss mailing list
FormEncode-discuss@???
https://lists.sourceforge.net/lists/listinfo/formencode-discuss