> I agree. Sometimes I think stripping should be a default for non-text,
> non-blob fields. Pros/cons?

Breaks backwards compatability. So under our banner of web2pyism, we can't
do it.

However, devnull, try this, this will alter the input before you validate it
through the form, so you can apply operators, such as stripping, or
.capitalize() or .upper() or anything really :P

def decode(string, strip="!...@#$%^&*()"):
   newstr = ""
   for char in string:
      if char not in strip:
         newstr += char
   return newstr

def myaction():
   if request.vars:
      request.vars.fieldname = decode(request.vars.fieldname)
   form = SQLFORM(db.tablename)

   if form.accepts(request.vars, session):
      response.flash = "yay"
   elif form.errors:
      response.flash = "nay"
   else:
      response.flash = "hey"

-Thadeus




On Sat, Oct 10, 2009 at 1:02 PM, JorgeR <[email protected]> wrote:

>
> I agree too.
>
> On Oct 10, 10:02 am, mdipierro <[email protected]> wrote:
> > I agree. Sometimes I think stripping should be a default for non-text,
> > non-blob fields. Pros/cons?
> >
> > On Oct 10, 7:52 am, devnull <[email protected]> wrote:
> >
> > > (re-posting since I think my previous message went to just one person)
> >
> > > Is there an option or a validator that will strip whitespace before
> > > applying remaining validators for a given field on a form?
> >
> > > Somewhat related: I tried the CLEANUP validator but the resulting
> > > variable still had characters like !...@#%^ in it. Maybe I mis-understood
> > > its purpose... perhaps it strips special characters for the other
> > > validators, but then when everything is done the original typed value
> > > gets sent? It would be cool if there were a validator that took a
> > > regex or a list of characters and stripped those from the input (so a
> > > phone field might ignore everything except digits).
> >
> > > I checked the documentation and for some reason the source code has
> > > strike-out markup over it.
> http://mdp.cti.depaul.edu/examples/static/epydoc/web2py.gluon.validat...
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" 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/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to