Package muntjac :: Package data :: Package validators :: Module abstract_validator :: Class AbstractValidator
[hide private]
[frames] | no frames]

Class AbstractValidator

source code

          object --+    
                   |    
validator.IValidator --+
                       |
                      AbstractValidator
Known Subclasses:

Abstract IValidator implementation that provides a basic IValidator implementation except the isValid method. Sub-classes need to implement the isValid method.

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 "null" if the value is None.


Authors:
Vaadin Ltd., Richard Lincoln

Version: 1.1.2

Instance Methods [hide private]
 
__init__(self, errorMessage)
Constructs a validator with the given error message.
source code
 
validate(self, value)
Checks the given value against this validator.
source code
 
getErrorMessage(self)
Returns the message to be included in the exception in case the value does not validate.
source code
 
setErrorMessage(self, errorMessage)
Sets the message to be included in the exception in case the value does not validate.
source code

Inherited from validator.IValidator: isValid

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 with the given error message.

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

validate(self, value)

source code 

Checks the given value against this validator. If the value is valid the method does nothing. If the value is invalid, an InvalidValueException is thrown.

Parameters:
  • value - the value to check
Raises:
Overrides: validator.IValidator.validate
(inherited documentation)

getErrorMessage(self)

source code 

Returns the message to be included in the exception in case the value does not validate.

Returns:
the error message provided in the constructor or using setErrorMessage.

setErrorMessage(self, errorMessage)

source code 

Sets the message to be included in the exception in case the value does not validate. The exception message is typically shown to the end user.

Parameters:
  • errorMessage - the error message. "{0}" is automatically replaced by the value that did not validate.