Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Private Attributes
validation.validators.RangeValidator.RangeValidator Class Reference

List of all members.

Public Member Functions

def __init__
def __call__

Public Attributes

 name
 minval
 maxval
 title
 description

Static Private Attributes

 __implements__ = IValidator

Detailed Description

Definition at line 9 of file RangeValidator.py.


Constructor & Destructor Documentation

def validation.validators.RangeValidator.RangeValidator.__init__ (   self,
  name,
  minval = 0.0,
  maxval = 0.0,
  title = '',
  description = '' 
)

Definition at line 12 of file RangeValidator.py.

00012 
00013     def __init__(self, name, minval=0.0, maxval=0.0, title='', description=''):
00014         self.name = name
00015         self.minval = minval
00016         self.maxval = maxval
00017         self.title = title or name
00018         self.description = description


Member Function Documentation

def validation.validators.RangeValidator.RangeValidator.__call__ (   self,
  value,
  args,
  kwargs 
)

Definition at line 19 of file RangeValidator.py.

00019 
00020     def __call__(self, value, *args, **kwargs):
00021         if len(args)>=1:
00022             minval=args[0]
00023         else:
00024             minval=self.minval
00025             
00026         if len(args)>=2:
00027             maxval=args[1]
00028         else:
00029             maxval=self.maxval
00030 
00031         assert(minval <= maxval)
00032         try:
00033             nval = float(value)
00034         except ValueError:
00035             return ("Validation failed(%(name)s): could not convert '%(value)r' to number" %
00036                     { 'name' : self.name, 'value': value})
00037         if minval <= nval < maxval:
00038             return 1
00039 
00040         return ("Validation failed(%(name)s): '%(value)s' out of range(%(min)s, %(max)s)" %
00041                 { 'name' : self.name, 'value': value, 'min' : minval, 'max' : maxval,})

Member Data Documentation

Definition at line 10 of file RangeValidator.py.

Definition at line 17 of file RangeValidator.py.

Definition at line 15 of file RangeValidator.py.

Definition at line 14 of file RangeValidator.py.

Definition at line 13 of file RangeValidator.py.

Definition at line 16 of file RangeValidator.py.


The documentation for this class was generated from the following file: