|
From: <sub...@co...> - 2005-11-19 22:57:33
|
Author: ianb
Date: 2005-11-19 22:57:27 +0000 (Sat, 19 Nov 2005)
New Revision: 1295
Modified:
FormEncode/trunk/docs/news.txt
FormEncode/trunk/formencode/validators.py
Log:
Changed StringBoolean canonical name to StringBool; added Int test
Modified: FormEncode/trunk/docs/news.txt
===================================================================
--- FormEncode/trunk/docs/news.txt 2005-11-19 22:55:05 UTC (rev 1294)
+++ FormEncode/trunk/docs/news.txt 2005-11-19 22:57:27 UTC (rev 1295)
@@ -4,6 +4,9 @@
SVN trunk
---------
+* Changed preferred name of ``StringBoolean`` to ``StringBool`` (to go
+ with ``bool`` and ``validators.Bool``). Old alias still available.
+
* Added ``today_or_after`` option to ``validators.DateValidator``.
* Added a ``validators.FileUploadKeeper`` validator for helping with
Modified: FormEncode/trunk/formencode/validators.py
===================================================================
--- FormEncode/trunk/formencode/validators.py 2005-11-19 22:55:05 UTC (rev 1294)
+++ FormEncode/trunk/formencode/validators.py 2005-11-19 22:57:27 UTC (rev 1295)
@@ -841,6 +841,9 @@
Always Valid, returns True or False based on the value and the
existance of the value.
+ If you want to convert strings like ``'true'`` to booleans, then
+ use ``StringBoolean``.
+
Examples::
>>> Bool.to_python(0)
@@ -863,6 +866,15 @@
"""
Convert a value to an integer.
+
+ Example::
+
+ >>> Int.to_python('10')
+ 10
+ >>> Int.to_python('ten')
+ Traceback (most recent call last):
+ ...
+ Invalid: Please enter an integer value
"""
messages = {
@@ -1643,7 +1655,7 @@
return field, v
-class StringBoolean(FancyValidator):
+class StringBool(FancyValidator):
# Originally from TurboGears
"""
Converts a string to a boolean.
@@ -1678,6 +1690,9 @@
else:
return self.false_values[0]
+# Should deprecate:
+StringBoolean = StringBool
+
class SignedString(FancyValidator):
"""
|