Some of the information here may be outdated, please check the book instead
[edit]

IS_EMAIL validator uses now more strict regular expression for email adresses and has two new parameters to control the domains:

INPUT(_type='text', _name='name', requires=IS_EMAIL(banned=None,
                                                    forced=None))
  1. banned: regular expression text for disallowed address domains
  2. forced: regular expression text for required address domains

Both arguments can also be custom objects with a match(value) method.

Examples:

Check for valid email address that can't be from a .com domain:

INPUT(_type='text', _name='name', requires=IS_EMAIL(banned='^.*\.com(|\..*)$'))

Will not validate for addresses with .com in domain, eg. foo@bar.com, foo@bar.com.baz

Check for valid email address that must be from a .edu domain:

INPUT(_type='text', _name='name', requires=IS_EMAIL(forced='^.*\.edu(|\..*)$'))

Will validate only for addresses with .edu in domain, eg. foo@bar.edu foo@bar.edu.baz

© 2008-2010 by Massimo Di Pierro - All rights reserved - Powered by web2py - design derived from a theme by the earlybird
The content of this book is released under the Artistic License 2.0 - Modified content cannot be reproduced.