1. Luke Macken
  2. formencode

Commits

Christoph Zwerschke  committed 82ad346

Applied patch #2789148 for adding docs on formencode.national.

  • Participants
  • Parent commits 5cc49d9
  • Branches default

Comments (0)

Files changed (5)

File docs/Validator.txt

View file
 --------------------
 
 There's lots of validators.  The best way to read about the individual
-validators available in the ``formencode.validators`` module is to
-read about :mod:`formencode.validators`.
+validators available in the ``formencode.validators`` module is to read
+about :mod:`formencode.validators` and :module:`formencode.national`.
 
 Compound Validators
 -------------------
 
     >>> import re
     >>> class SecurePassword(validators.FancyValidator):
-    ... 
+    ...
     ...     min = 3
     ...     non_letter = 1
     ...     letter_regex = re.compile(r'[a-zA-Z]')
-    ... 
+    ...
     ...     messages = {
     ...         'too_few': 'Your password must be longer than %(min)i '
     ...                   'characters long',
     ...         'non_letter': 'You must include at least %(non_letter)i '
     ...                      'characters in your password',
     ...         }
-    ... 
+    ...
     ...     def _to_python(self, value, state):
     ...         # _to_python gets run before validate_python.  Here we
     ...         # strip whitespace off the password, because leading and
     ...         # trailing whitespace in a password is too elite.
     ...         return value.strip()
-    ... 
+    ...
     ...     def validate_python(self, value, state):
     ...         if len(value) < self.min:
-    ...             raise Invalid(self.message("too_few", state, 
+    ...             raise Invalid(self.message("too_few", state,
     ...                                        min=self.min),
     ...                           value, state)
     ...         non_letters = self.letter_regex.sub('', value)
     ...         if len(non_letters) < self.non_letter:
-    ...             raise Invalid(self.message("non_letter", 
+    ...             raise Invalid(self.message("non_letter",
     ...                                         non_letter=self.non_letter),
     ...                           value, state)
 
 There are several options that most validators support (including your
 own validators, if you subclass from
 :class:`formencode.api.FancyValidator`):
-    
+
 ``if_empty``:
       If set, then this value will be returned if the input evaluates
       to false (empty list, empty string, None, etc), but not the 0 or
       False objects.  This only applies to ``.to_python()``.
-      
+
 ``not_empty``:
       If true, then if an empty value is given raise an error.
       (Both with ``.to_python()`` and also ``.from_python()``
 ``if_invalid``:
       If set, then when this validator would raise Invalid during
       ``.to_python()``, instead return this value.
-      
+
 ``if_invalid_python``:
       If set, when the Python value (converted with
       ``.from_python()``) is invalid, this value will be returned.
 And the test for your language::
 
     def test_<lang>():
-        _test_lang("<lang>", u"<translation of Not Empty Text in the language <lang>") 
+        _test_lang("<lang>", u"<translation of Not Empty Text in the language <lang>")
 
 HTTP/HTML Form Input
 --------------------

File docs/modules/national.txt

View file
+:mod:`formencode.national` -- Country specific validators
+=========================================================
+
+.. automodule:: formencode.national
+
+.. contents::
+
+Module Contents
+---------------
+
+.. admonition:: Note
+
+   To use CountryValidator and LanguageValidator, install either
+   `pycountry <http://pypi.python.org/pypi/pycountry/0.10>`__ or
+   `TurboGears <http://turbogears.org>`__.
+
+Country, State, and Postal Codes
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. autoclass:: DelimitedDigitsPostalCode
+.. autofunction:: USPostalCode
+.. autofunction:: GermanPostalCode
+.. autofunction:: FourDigitsPostalCode
+.. autofunction:: PolishPostalCode
+.. autoclass:: ArgentinianPostalCode
+.. autoclass:: CanadianPostalCode
+.. autoclass:: UKPostalCode
+.. autoclass:: CountryValidator
+.. autoclass:: PostalCodeInCountryFormat
+.. autoclass:: USStateProvince
+
+Phones and Addresses
+~~~~~~~~~~~~~~~~~~~~
+
+.. autoclass:: USPhoneNumber
+.. autoclass:: InternationalPhoneNumber
+
+Language Codes and Names
+~~~~~~~~~~~~~~~~~~~~~~~~
+.. autoclass:: LanguageValidator
+

File docs/modules/validators.txt

View file
 .. autoclass:: TimeConverter
 
 
-Phones and Addresses
-~~~~~~~~~~~~~~~~~~~~
-
-.. autoclass:: PhoneNumber
-.. autoclass:: IPhoneNumberValidator
-.. autoclass:: StateProvince
-.. autoclass:: PostalCode
-
 HTML Form Helpers
 ~~~~~~~~~~~~~~~~~
 

File docs/modules/variabledecode.txt

View file
 
 .. autofunction:: variable_decode
 .. autofunction:: variable_encode
-.. autofunction:: NestedVariables
+.. autoclass:: NestedVariables
 

File formencode/national.py

View file
+"""
+Country specific validators for use with FormEncode.
+"""
 import re
 
 from api import FancyValidator