Package s3 :: Module s3validators
[frames] | no frames]

Module s3validators

source code

Custom Validators


Requires: gluon

Copyright: (c) 2010-2019 Sahana Software Foundation

License: MIT

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Classes
  IS_JSONS3
Similar to web2py's IS_JSON validator, but extended to handle single quotes in dict keys (=invalid JSON) from CSV imports.
  IS_LAT
example:
  IS_LON
example:
  IS_LAT_LON
Designed for use within the S3LocationLatLonWidget.
  IS_INT_AMOUNT
Validation, widget and representation of integer-values with thousands-separators
  IS_FLOAT_AMOUNT
Validation, widget and representation of float-values with thousands-separators
  IS_HTML_COLOUR
example:
  IS_ONE_OF_EMPTY
Filtered version of IS_IN_DB():
  IS_ONE_OF
Extends IS_ONE_OF_EMPTY by restoring the 'options' method.
  IS_ONE_OF_EMPTY_SELECT
Extends IS_ONE_OF_EMPTY by displaying an empty SELECT (instead of INPUT)
  IS_NOT_ONE_OF
Filtered version of IS_NOT_IN_DB()
  IS_LOCATION
Allow all locations, or locations by level.
  IS_PROCESSED_IMAGE
Uses an S3ImageCropWidget to allow the user to crop/scale images and processes the results sent by the browser.
  IS_UTC_OFFSET
Validates a given string value as UTC offset in the format +/-HHMM
  IS_UTC_DATETIME
Validates a given date/time and returns it as timezone-naive datetime object in UTC.
  IS_UTC_DATE
Validates a given date and returns the corresponding datetime.date object in UTC.
  IS_ACL
Validator for ACLs
  IS_COMBO_BOX
Designed for use with an Autocomplete.
  QUANTITY_INV_ITEM
For Inventory module
  IS_IN_SET_LAZY
Like IS_IN_SET but with options obtained from a supplied function.
  IS_PERSON_GENDER
Special validator for pr_person.gender and derivates, accepts the "O" option even if it's not in the set.
  IS_PHONE_NUMBER
Validator for single phone numbers with option to enforce E.123 international notation (with leading + and no punctuation or spaces).
  IS_PHONE_NUMBER_MULTI
Validator for multiple phone numbers.
  IS_DYNAMIC_FIELDNAME
Validator for field names in dynamic tables
  IS_DYNAMIC_FIELDTYPE
Validator for field types in dynamic tables
  IS_ISO639_2_LANGUAGE_CODE
Validate ISO639-2 Alpha-2/Alpha-3 language codes
Variables
  single_phone_number_pattern = "%s$" % phone_number_pattern
  multi_phone_number_pattern = r"%s(\s*(,|/|;)\s*%s)*$" %(phone_...
  s3_single_phone_requires = IS_MATCH(single_phone_number_pattern)
  s3_phone_requires = IS_MATCH(multi_phone_number_pattern, error...
Variables Details

single_phone_number_pattern

Value:
"%s$" % phone_number_pattern

multi_phone_number_pattern

Value:
r"%s(\s*(,|/|;)\s*%s)*$" %(phone_number_pattern, phone_number_pattern)

s3_single_phone_requires

Value:
IS_MATCH(single_phone_number_pattern)

s3_phone_requires

Value:
IS_MATCH(multi_phone_number_pattern, error_message= "Invalid phone num\
ber!")