Package muntjac :: Package data :: Package validators :: Module abstract_string_validator :: Class AbstractStringValidator
[hide private]
[frames] | no frames]

Class AbstractStringValidator

source code

                      object --+        
                               |        
            validator.IValidator --+    
                                   |    
abstract_validator.AbstractValidator --+
                                       |
                                      AbstractStringValidator

Validator base class for validating strings. See AbstractValidator for more information.

To include the value that failed validation in the exception message you can use "{0}" in the error message. This will be replaced with the failed value (converted to string using __str__) or "None" if the value is None.


Authors:
Vaadin Ltd., Richard Lincoln

Version: 1.1.2

Instance Methods [hide private]
 
__init__(self, errorMessage)
Constructs a validator for strings.
source code
 
isValid(self, value)
Tests if the given value is a valid string.
source code
 
isValidString(self, value)
Checks if the given string is valid.
source code

Inherited from abstract_validator.AbstractValidator: getErrorMessage, setErrorMessage, 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, errorMessage)
(Constructor)

source code 

Constructs a validator for strings.

None and empty string values are always accepted. To reject empty values, set the field being validated as required.

Parameters:
  • errorMessage - the message to be included in an InvalidValueException (with "{0}" replaced by the value that failed validation).
Overrides: object.__init__

isValid(self, value)

source code 

Tests if the given value is a valid string.

None values are always accepted. Values that are not strings are converted using __str__. Then isValidString is used to validate the value.

Parameters:
  • value - the value to check
Returns:
true if the value (or its __str__) is a valid string, false otherwise
Overrides: validator.IValidator.isValid

isValidString(self, value)

source code 

Checks if the given string is valid.

Parameters:
  • value - String to check. Can never be None.
Returns:
true if the string is valid, false otherwise