Package muntjac :: Package data :: Package validators :: Module string_length_validator :: Class StringLengthValidator
[hide private]
[frames] | no frames]

Class StringLengthValidator

source code

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

This StringLengthValidator is used to validate the length of strings.


Authors:
Vaadin Ltd., Richard Lincoln

Version: 1.1.2

Instance Methods [hide private]
 
__init__(self, errorMessage, minLength=None, maxLength=None, allowNull=None)
Creates a new StringLengthValidator with a given error message, permissable lengths and null-string allowance.
source code
 
isValid(self, value)
Checks if the given value is valid.
source code
 
isNullAllowed(self)
Returns True if null strings are allowed.
source code
 
getMaxLength(self)
Gets the maximum permissible length of the string.
source code
 
getMinLength(self)
Gets the minimum permissible length of the string.
source code
 
setNullAllowed(self, allowNull)
Sets whether null-strings are to be allowed.
source code
 
setMaxLength(self, maxLength)
Sets the maximum permissible length of the string.
source code
 
setMinLength(self, minLength)
Sets the minimum permissible length.
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, minLength=None, maxLength=None, allowNull=None)
(Constructor)

source code 

Creates a new StringLengthValidator with a given error message, permissable lengths and null-string allowance.

Parameters:
  • errorMessage - the message to display in case the value does not validate.
  • minLength - the minimum permissible length of the string.
  • maxLength - the maximum permissible length of the string.
  • allowNull - Are null strings permissible? This can be handled better by setting a field as required or not.
Overrides: object.__init__

isValid(self, value)

source code 

Checks if the given value is valid.

Parameters:
  • value - the value to validate.
Returns:
True for valid value, otherwise False.
Overrides: validator.IValidator.isValid

isNullAllowed(self)

source code 

Returns True if null strings are allowed.

Returns:
True if allows null string, otherwise False.

getMaxLength(self)

source code 

Gets the maximum permissible length of the string.

Returns:
the maximum length of the string.

getMinLength(self)

source code 

Gets the minimum permissible length of the string.

Returns:
the minimum length of the string.

setNullAllowed(self, allowNull)

source code 

Sets whether null-strings are to be allowed. This can be better handled by setting a field as required or not.

setMaxLength(self, maxLength)

source code 

Sets the maximum permissible length of the string.

Parameters:
  • maxLength - the length to set.

setMinLength(self, minLength)

source code 

Sets the minimum permissible length.

Parameters:
  • minLength - the length to set.