This file is part of the web2py Web Framework Copyrighted by Massimo
Di Pierro <mdipierro@cs.depaul.edu> License: LGPLv3
(http://www.gnu.org/licenses/lgpl.html)
Thanks to ga2arch for help with IS_IN_DB and IS_NOT_IN_DB on GAE
|
|
Validator
Root for all validators, mainly for documentation purposes.
|
|
|
IS_MATCH
example:
|
|
|
IS_EQUAL_TO
example:
|
|
|
IS_EXPR
example:
|
|
|
IS_LENGTH
Checks if length of field's value fits between given
boundaries.
|
|
|
IS_IN_SET
example:
|
|
|
IS_IN_DB
example:
|
|
|
IS_NOT_IN_DB
example:
|
|
|
IS_INT_IN_RANGE
Determine that the argument is (or can be represented as) an
int, and that it falls within the specified range.
|
|
|
IS_FLOAT_IN_RANGE
Determine that the argument is (or can be represented as) a
float, and that it falls within the specified inclusive range.
|
|
|
IS_DECIMAL_IN_RANGE
Determine that the argument is (or can be represented as) a
Python Decimal, and that it falls within the specified inclusive
range.
|
|
|
IS_NOT_EMPTY
example:
|
|
|
IS_ALPHANUMERIC
example:
|
|
|
IS_EMAIL
Checks if field's value is a valid email address.
|
|
|
IS_GENERIC_URL
Rejects a URL string if any of the following is true:
* The string is empty or None
* The string uses characters that are not allowed in a URL
* The URL scheme specified (if one is specified) is not valid
Based on RFC 2396: http://www.faqs.org/rfcs/rfc2396.html
This function only checks the URL's syntax.
|
|
|
IS_HTTP_URL
Rejects a URL string if any of the following is true:
* The string is empty or None
* The string uses characters that are not allowed in a URL
* The string breaks any of the HTTP syntactic rules
* The URL scheme specified (if one is specified) is not 'http' or 'https'
* The top-level domain (if a host name is specified) does not exist
Based on RFC 2616: http://www.faqs.org/rfcs/rfc2616.html
This function only checks the URL's syntax.
|
|
|
IS_URL
Rejects a URL string if any of the following is true:
* The string is empty or None
* The string uses characters that are not allowed in a URL
* The string breaks any of the HTTP syntactic rules
* The URL scheme specified (if one is specified) is not 'http' or 'https'
* The top-level domain (if a host name is specified) does not exist
(These rules are based on RFC 2616: http://www.faqs.org/rfcs/rfc2616.html)
This function only checks the URL's syntax.
|
|
|
IS_TIME
example:
|
|
|
IS_DATE
example:
|
|
|
IS_DATETIME
example:
|
|
|
IS_DATE_IN_RANGE
example:
|
|
|
IS_DATETIME_IN_RANGE
example:
|
|
|
IS_LIST_OF
|
|
|
IS_LOWER
convert to lower case
|
|
|
IS_UPPER
convert to upper case
|
|
|
IS_SLUG
convert arbitrary text string to a slug
|
|
|
IS_EMPTY_OR
dummy class for testing IS_EMPTY_OR
|
|
|
IS_NULL_OR
dummy class for testing IS_EMPTY_OR
|
|
|
CLEANUP
example:
|
|
|
CRYPT
example:
|
|
|
IS_STRONG
example:
|
|
|
IS_IN_SUBSET
|
|
|
IS_IMAGE
Checks if file uploaded through file input was saved in one of
selected image formats and has dimensions (width and height) within
given boundaries.
|
|
|
IS_UPLOAD_FILENAME
Checks if name and extension of file uploaded through file input matches
given criteria.
|
|
|
IS_IPV4
Checks if field's value is an IP version 4 address in decimal form.
|
|
|
|
|
|
|
|
|
|
|
|
is_empty(value,
empty_regex=global_settings.applications_parent)
test empty field |
source code
|
|
|
|
|
|
|
|
|
|
|
|
|
urlify(value,
maxlen=80,
keep_underscores=True)
Convert incoming string to a simplified ASCII subset. |
source code
|
|
|
|
regex1 = re.compile(r'[\w_]+\.[\w_]+')
|
|
|
regex2 = re.compile(r'%\((?P<name>[^\)]+)\)s')
|
|
|
official_url_schemes = ['aaa', 'aaas', 'acap', 'cap', 'cid', '...
|
|
|
unofficial_url_schemes = ['about', 'adiumxtra', 'aim', 'afp', ...
|
|
|
all_url_schemes = [None, 'aaa', 'aaas', 'acap', 'cap', 'cid', ...
|
|
|
http_schemes = [None, 'http', 'https']
|
|
|
url_split_regex = re.compile(r'^(([^:/\?#]+):)?(//([^/\?#]*))?...
|
|
|
label_split_regex = re.compile(r'[\.\u3002\uff0e\uff61]')
|
|
|
official_top_level_domains = ['ac', 'ad', 'ae', 'aero', 'af', ...
|
|
|
regex_time = re.compile(r'((?P<h>[0-9]+))([^0-9 ]+(?P<m>[0-9 ]...
|