On Jan 26, 2:30 pm, Wyatt Baldwin <[email protected]> wrote:
> On Jan 26, 2:33 am, eleith <[email protected]> wrote:
>
>
>
> > for my schema, i want to handle
> > ----------------------------------------
> > delete?id=100
> > delete?id=100&id=101&id=102
>
> > and throw an error for
>
> > delete?
> > -----------------------------------------
> > my validators look like this:
>
> > id = ForEach(Int(), not_empty=True, convert_to_list=True)
>
> > however, this passes when even when i don't pass in an 'id'
>
> > i've even tried
>
> > All(NotEmpty(), ForEach(....))
>
> > that doesn't work either. i've ended up writing my own function and
> > subclassing into SimpleFormValidator to handle this case for me (i
> > just check if the len(values['id']) < 1, and return an error message)
>
> > so either i'm going about this the wrong way, or there is an error in
> > ForEach and/or All.
>
> > any suggestions? (although, i'm happy with my solution, just thought i
> > would publish my findings)
>
> Have you seen the Pipe compound validator? I haven't used it, but I
> wonder it if might work for this.
>
> After taking a peek at the source[1], this might work, too:
>
>     ForEach(NotEmpty(), Int())
>
> [1]http://www.formencode.org/formencode/foreach.py.html?f=15&l=126#15

>From what I am seeing in the code, it isn't about ForEach not properly
validating, it is about the fact that if no arguments are passed,
there is no entry in to the validation loop. So it doesn't get a
chance to throw the validation errors. So you'd experience the same
problem as before when not actually passing in a value. If you passed
in a blank id or an id that wasn't an integer that would catch it and
throw the validation error accordingly.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to