something like this? def MYVALIDATOR: def __init__(self,error_message): self.error_message=error_message def __call__(self,value): if not re.compile('^([a-zA-Z]*[ ]*[á]*[é]*[í]*[ó]*[ú]*)+ $').match(value): return (value,self.error_message) else: newvalue='' for c in value: if c in 'áéíóú': new_values+=self.do_something(c) else: newvalue+=c.upper() return (newvalue,None) def do_something(self,c): return {'á':"A'",'é':"E'",'í':"I'",'ó':"O'",'ú':"U'"}[c]
requires=MYVALIDATOR() On Oct 3, 1:19 am, Sophie <kfarron...@gmail.com> wrote: > I solve this with this code > IS_UPPER(),IS_MATCH('([a-zA-Z]*[ ]*[á]*[é]*[í]*[ó]*[ú]*) > +',error_message='Solo se permite a-z, A-Z y espacios') > > the problem is that i insert Perú, in the database i see PERú, the ú > is not upper it should appear Ú what can i do for this? > > On 1 oct, 19:53, Sophie <kfarron...@gmail.com> wrote: > > > For acute what can i do. I see examples for php '/&([aeioun])(acute| > > tilde); > > i dont find for python > > > On 1 oct, 19:21, Yarko Tymciurak <yark...@gmail.com> wrote: > > > > On Thu, Oct 1, 2009 at 5:45 PM, Sophie <kfarron...@gmail.com> wrote: > > > > > IS_MATCH('[a-zA-Z]+',error_message='Only charaters allowed') > > > > This reads: > > > > any string of one or more of any combination of upper or lower case > > > letters... > > > > > This works but if i want to add spaces, for las name for example: De > > > > La Rosa > > > > How can i do this? > > > > You can group regular expressions, e.g.: > > > > ([A-Z][a-z]*[ ]*)+ > > > > You can test the results with tools, e.g.http://www.pythonregex.com/ > > > > > On 1 oct, 16:46, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > > This: > > > > > > requires=[IS_NOT_EMPTY('Please insert a country name'), > > > > > IS_UPPER(), IS_NOT_IN_DB(db,'Country.nCountry','This country is > > > > > already in the database')], > > > > > > should already do what you asked as long as you do not have already > > > > > data in the DB. > > > > > > You can add one more validator instead > > > > > IS_MATCH('[a-zA-Z]+',error_message='Only charaters allowed') > > > > > > What about Cote' d'Ivoire? > > > > > > On Oct 1, 4:11 pm, Sophie <kfarron...@gmail.com> wrote: > > > > > > > Hi there my problem is when i validate myinput, i have this code in > > > > > > the model > > > > > > > db.define_table("Country", > > > > > > Field("nCountry", "string", default=None, label="Name", > > > > > > notnull=True, requires=[IS_NOT_EMPTY('Please insert a country > > > > > > name'), > > > > > > IS_UPPER(), IS_NOT_IN_DB(db,'Country.nCountry','This country is > > > > > > already in the database')], ondelete='CASCADE')) > > > > > > > So when i start inserting data i have duplicate data like this: > > > > > > Brazil, BRazil, BRAzil, braZil. > > > > > > > This is the same country, but is written in different ways. There > > > > > > is a > > > > > > way to validate this? > > > > > > > The other problem i have is that i can insert Br4zil, but i want it > > > > > > to > > > > > > receive only alphabetical inputs. > > > > > > > Well thats all thanks a lot. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---