Re: decorating validators, CompoundValidator

Ian Bicking <[email protected]> Tue, 20 May 2008 10:58:44 -0400
Newsgroups gmane.comp.python.formencode
Message-ID <[email protected]>
W-Mark Kubacki wrote:
> Hi group,
> hello Ian,
> 
> Can we introduce a Consecutive/Stepper/Decorating validator or reanimate the 
> CompoundValidator, so the developer can combine decorators?
>     email = Decorating(String(), Email())
> This could basically act like All but the output of the left validator is 
> handled over to its right neighbor. (And vice versa, in case of from_python())
>     # value is the input
>     # op in ['to_python', 'from_python']
>     # I will leave out reversion of decorated_validators for the latter.
>     for validator in decorated_validators:
>         value = getattr(validator, op)(value)
>     return value
> 
> What do you think? Is there a more efficient way?

I'd like one, I just can't think of the name.  Unfortunately, and not 
quite intentionally, All ended up being in this kind of reversed-order, 
and fixing it would cause problematic compatibility problems elsewhere. 
  Maybe And()?

-- 
Ian Bicking : [email protected] : http://blog.ianbicking.org

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft 
Defy all challenges. Microsoft(R) Visual Studio 2008. 
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/