PostalCode

US Postal codes (aka Zip Codes).

>>> PostalCode.to_python('55555')
'55555'
>>> PostalCode.to_python('55555-5555')
'55555-5555'
>>> PostalCode.to_python('5555')
Traceback (most recent call last):
    ...
Invalid: Please enter a zip code (5 digits)

Messages

badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
invalid:
Please enter a zip code (5 digits)
noneType:
The input must be a string (not None)

Attributes

a gettextargs

{}

a regexOps

()

a strip

True

a use_builtins_gettext

True

a regex

'^\\d\\d\\d\\d\\d(?:-\\d\\d\\d\\d)?$'

a accept_python

True

a __singletonmethods__

('to_python', 'from_python', 'message', 'all_messages', 'subvalidators')

a declarative_count

39

a __unpackargs__

('regex',)

a compound

False

a not_empty

False

a __mutableattributes__

()

a repeating

False

Methods

f __initargs__(self, new_attrs) ...

f __call__(self, *args, **kw) ...

f __classinit__(cls, new_attrs) ...

f __sourcerepr__(self, source, binding=None) ...

f __classsourcerepr__(cls, source, binding=None) ...

f __init__(self, *args, **kw) ...

f validate_python(self, value, state) ...

See the source for more information.