Module: fields
Translation of raw user input into validated Python values.
The field protocol consists of the following three methods:
- required(self): Return whether a value is mandatory for the field.
- has_value(self, input): Return whether a value has been provided for the field in the given MultiDict of user input. This method should return true even if the input value is invalid or malformed. In brief, it should return whether translation will raise an exception or return a non-None value.
- translate(self, input): Transform a subset of a MultiDict into an atomic Python value, or raise either TranslationError or ErrorSet if input is malformed.
For fields that expect only one parameter, only the value with the final matching key in the MultiDict of input is used, unless otherwise noted.
Classes
Boolean
Field for truth values following a three-valued logic (i.e. true, false, and unknown or not applicable); in brief, a nullable boolean.
Choice
Field for choosing an item from a set of options.
Date
Field for dates.
Decimal
Field for arbitrary precision numbers, implemented using the decimal module from the standard library.
A field for e-mail addresses.
File
Field for uploaded files.
Float
Field to hold floating-point values.
Integer
Field to hold integer values.
MultiChoice
Field for multiple choices from among a set of strings.
Password
Field for passwords.
Phone
Field for United States telephone numbers.
Regex
A field that is validated by a specifiable regular expression, and otherwise treated as a string.
String
Field for strings.
SubForm
Container for a set of fields to be treated together as a single field.
Time
Field for times on a 12-hour clock.
Toggle
Field that has two states, either on or off.
TranslationError
Exception for when translation of a field fails.
ZipCode
Field for United States postal codes.