New IS_EMAIL validator

[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