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

New IS_IPV4 validator checks if field's value is an IP version 4 address in decimal form.

Can be set to force adresses from certain range.

INPUT(_type='text',_name='name',requires=IS_IPV4(minip='0.0.0.0',
                                                 maxip='255.255.255.255'),
                                                 error_message='invalid IPv4
                                                                address!'))
  1. minip: lowest allowed address; accepts: str (eg. 192.168.0.1), iterable of numbers (eg. [192, 168, 0, 1]) or int (eg. 3232235521)
  2. maxip: highest allowed address; same as above

All three example values are equal, since addresses are converted to integers for inclusion check with following function:

number = 16777216 * IP[0] + 65536 * IP[1] + 256 * IP[2] + IP[3]

Examples:

Check for valid IPv4 address:

INPUT(_type='text',_name='name',requires=IS_IPV4())

Check for valid private network IPv4 address:

INPUT(_type='text',_name='name',requires=IS_IPV4(minip='192.168.0.1',
                                                 maxip='192.168.255.255'))
© 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.