Hi, we are not using deform as the form lib, but we rely on the colander to
do the validation. BTW, we found the soution:
@colander.deferred
def deferred_password_validator(node, kw):
password = kw.get('password')
re_password = kw.get('re_password')
if password != re_password:
errmsg = "Password did not match confirm"
e = colander.Invalid(node,errmsg)
raise exception.ValidationFailure(node, '', e)
On Fri, May 25, 2012 at 12:03 AM, Mariano Mara <[email protected]>wrote:
> Quoting george hu (2012-05-22 23:34:30)
> > I have the following deferred validator:
> > @colander.deferred
> > def deferred_password_validator(node, kw):
> > password = kw.get('password')
> > re_password = kw.get('re_password')
> > if password != re_password:
> > raise colander.Invalid(node, 'Password did not match confirm')
> >
> > Then I try to capture the exception:
> > try:
> > form.validate(....)
> > except ValidationFailure, e:
> > error_dict = e.error.asdict()
> >
> >
> > However when the program runs, it just breaks into terminal, showing:
> > Invalid: {'re_password': 'Password did not match confirm'}
> >
> > Can anybody help me to see where is the problem?
> >
> > Thanks
>
> I have two questions:
> Why do you use a deferred for that kind of validation? A simple validation
> function should be more than enough.
> Besides that, do you know Deform already provides such validation? See [1]
>
> Mariano
>
> [1] http://deformdemo.repoze.org/checkedpassword/
>
> --
> 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.
>
>
--
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.