> > > > TextField(validator=Int()) -> field not required
> > > > TextField(validator=Int(), is_required=True) -> field required
> > > > TextField(validator=Int(not_empty=True)) -> field_required
> > > > TextField(validator=Int(not_empty=True), is_required=False) ->
> > > > field_required
>
> I don't like this solution that much anyway, I've prepared a patch for
> FE to manage not_empty in the right way, let's see what Ian thinks (I
> emailed him), then we could do this in a easier and cleaner way. ;-)
>
> The idea is to provide a validator_args (better name anyone?) parameter
> that let's you specify additional args without providing a new
> validator:
>
> TextField(validator_args={'not_empty':True})
>
> this is more coherent IMHO, and let's us define a clear policy:
>
> TextField(validator=Int(not_empty=False),
> validator_args={'not_empty':True})
>
> if the parameter is already specified in the validator this takes the
> precedence, moreover the above case will (hopefully) never happen since
> if you are providing a new validator you will not use validator_args
> (unless your are crazy and want to be not DRY). ;-)
I must say the former solution is much more appealing to me.
I think it's natural to expect that user can denote field as "required". This
information is important to display as much as to actual validation. And
TextField(..., is_required=True) does this just fine.
To specify data validation/conversion current syntax can be used:
TextField(validator=Int(not_empty=True)))
If is_required is set, it can override validator's not_empty param and/or raise
exception on mismatch.
I can propose another syntax which somewhat cleaner but not backward-compatible:
TextField(validator=Int, is_required=False, **extra_validator_args)
Note that validator specify class object, not an instance. FormField would
instantiate validator using is_required and extra_validator_args if any.
My 2 cents.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---