Alberto, Michele,

> > TextField(is_required=True)
> >
> > but this is more explicit of what's going on, doesn't hide FE and
> > follows the Widget philosophy or reusing FE and it's feature (not only
> > a simple validator but also a Schema).
> >
> > TextField(validator=NotEmpty())
> 
> Agree

Sure.

One thing. If I'm not mistaken there is no standard way in validator's API to 
check "not_emptiness" except trying to validate an empty string, which is kinda 
broken (e.g. validators.String(not_empty=False, if_invalid='abc')).

And I argue that TextField may need to know whether it is required or not 
regardless of validator. For instance, to display itself differently. And if 
you agree with that and agree that querying validator about it not an option 
then adding "is_required" is the only way to go.

Now the question is how to "combine" is_required with validator. A couple of 
variants has been proposed, here is one more: chain user-supplied validator 
with NotEmpty() validator if is_required==True. 
 
Another option is not to combine them at all. Attribute "is_required" related 
to view and let it be separate from whatever validatation method is used. This 
arguably breaks DRY as you would have to write TextField(is_required=True, 
validator=Int(not_empty=True)) but OTOH explicit is better than implicit.

> > the solution I'm proposing is needed for such widget that already
> > provide a default validator (SelectionField, FileField in the future)
> > and when you would like to tweak some parameters without redefining
> > the entire validator:
> >
> > MultipleSelectionField(validators_args={'not_empty':True})

Above you wrote that you didn't want to hide fE and here you're proposing 
widget to provide default validator.
 
 


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears Trunk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears-trunk
-~----------~----~----~----~------~----~------~--~---

Reply via email to