Package konval :: Module stringval :: Class IsPlainText
[hide private]
[frames] | no frames]

Class IsPlainText

source code

                 object --+        
                          |        
basevalidator.BaseValidator --+    
                              |    
                   IsRegexMatch --+
                                  |
                                 IsPlainText

Check the value only contains alphanumerics, underscores & hyphen.

Useful for checking identifiers.

For example:

>>> v = IsPlainText()
>>> v ('abcd')
'abcd'
>>> v ('ab cd')
Traceback (most recent call last):
...
ValueError: 'ab cd' is not plain text
>>> v ('ab!cd')
Traceback (most recent call last):
...
ValueError: 'ab!cd' is not plain text

Idea flinched from FormEncode.

Instance Methods [hide private]
 
__init__(self)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
make_validation_error_msg(self, bad_val, err)
Generate an meaningful error message for an empty value.
source code

Inherited from IsRegexMatch: validate_value

Inherited from basevalidator.BaseValidator: __call__, convert, convert_value, make_conversion_error_msg, raise_conversion_error, raise_validation_error, validate

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)

make_validation_error_msg(self, bad_val, err)

source code 
Generate an meaningful error message for an empty value.
Overrides: basevalidator.BaseValidator.make_validation_error_msg