Hi Ryan, In your example below, _to_python always works for me if I call it directly (as a method of the class). Is there any chance that your controller isn't calling it when the value is an empty string? It might help to see how your controller is referencing it.
Best, Eric On Fri, Aug 13, 2010 at 7:46 AM, Ryan <[email protected]> wrote: > I have a custom validator called `FlexPassword` > > class FlexPassword(formencode.FancyValidator): > def _to_python(self, value, state): > raise formencode.Invalid('validator ran', value, state) > > Here's my schema: > > password = > formencode.All(formencode.validators.PlainText(not_empty=True), > FlexPassword()) > > As expected, when no characters are entered, the PlainText error is > raised. Also as expected, when a single character is entered, the > FlexPassword error is raised. > > But that's not the schema I want to use. This is: > > password = formencode.All(FlexPassword()) > > Contrary to expectation, when no characters are entered, the > FlexPassword error is not raised. Huh? As expected, when a single > character is entered, the FlexPassword error is raised. > > The way I've got it wired up, the form should always fail validation, > but with a blank password, it passes. Any insights for me? Thanks. > > -- > You received this message because you are subscribed to the Google Groups > "pylons-discuss" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<pylons-discuss%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/pylons-discuss?hl=en. > > -- You received this message because you are subscribed to the Google Groups "pylons-discuss" 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/pylons-discuss?hl=en.
