Package qanda :: Module validators :: Class BaseValidator
[hide private]
[frames] | no frames]

Class BaseValidator

source code

object --+
         |
        BaseValidator
Known Subclasses:

A base class for custom validators.

Ideally, this should make validator subclasses simple to construct. Derived valuidators will often only have to override one method (of __call__, convert and validate) and perhaps supply a c'tor.

Instance Methods [hide private]
 
__call__(self, value)
Converts and validates user input.
source code
 
validate(self, value)
Is this value correct or of the correct form?
source code
 
convert(self, value)
Transform this value to the desired form.
source code

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

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__call__(self, value)
(Call operator)

source code 

Converts and validates user input.

Should throw an error if any problems. Override in subclass if required.

Parameters:
  • value - value to be checked or transformed
Returns:
the transformed or validated value

validate(self, value)

source code 

Is this value correct or of the correct form?

Should throw an exception if validations fails. Override in subclass if required.

Parameters:
  • value - value to be checked

convert(self, value)

source code 

Transform this value to the desired form.

Can throw if conversion fails. Override in subclass if required.

Parameters:
  • value - value to be transformed
Returns:
the transformed value