bad_names = ['list', 'of', 'bad', 'names'] db.define_table(..., Field('name', requires=IS_MATCH(r'^(?!%s)' % '|'.join('%s$' % w for w in bad_names)), ...)
The above will produce a regular expression like: r'^(?!list$|of$|bad$|names$)' which will match anything except what is in the list. Alternatively, you could make a custom validator: http://web2py.com/books/default/chapter/29/07/forms-and-validators#Custom-validators Anthony On Wednesday, April 13, 2016 at 6:20:12 AM UTC-4, Stephen Duisberg wrote: > > db.define_table('person', > Field('name'), > Field('pic','upload') > ) > > What should I do such that the name field won't accept names with some > words like 'the', 'rock' and all. > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.