Home | Trees | Indices | Help |
---|
|
object --+ | basevalidator.BaseValidator --+ | vocabval.Synonyms --+ | StrToBool
Converts common abbreviations for true-false to boolean values.
This converts common abbreviations for true/false to actual Booleans. Case and flanking spaces are ignored. The allowed values are defined in defs. For example:
>>> v = StrToBool() >>> v("True") True >>> v("f") False >>> v(" on ") True >>> v("0") False >>> v("yEs") True >>> v("maybe") Traceback (most recent call last): ... ValueError: can't recognise MAYBE' as true or false
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from Inherited from |
|
|||
Inherited from |
|
For example: >>> d = {'foo': 1, 'bar': 2} >>> v = Synonyms(d) >>> v('foo') 1 >>> v('quux') 'quux'
|
Transform a value to the desired form. This is the workhorse method that is called by convert to transform passed values. As such, errors are signalled by throwing a meaningful exception. This is one of the obvious and easiest places to customize behaviour by overriding in a subclass.
|
Check a value is of the desired form. This is the workhorse method that is called by validate to check passed values. As such, errors are signalled by either by throwing a meaningful exception or by returning false. This is one of the obvious and easiest places to customize behaviour by overriding in a subclass.
|
Generate an error message for a validation problem. Parameters as per raise_validation_error. Override in subclass if need be, for more specific and meaningful messages.
|
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Fri Jul 22 15:13:46 2011 | http://epydoc.sourceforge.net |