source: products/ShortMessage/trunk/validators.py @ 1

Last change on this file since 1 was 1, checked in by myroslav, 18 years ago

Building directory structure

File size: 856 bytes
Line 
1# Author: Melnychuk Taras
2# Contact: fenix@quintagroup.com
3# Date: $Date: 2005-11-23 13:15:21 +0200 (Thu, 23 Nov 2005) $
4# Copyright: quintagroup.com
5
6"""In this module define MaxSmValidator class that validate text block not more then 160 symbols"""
7
8__docformat__ = 'restructuredtext'
9
10from Products.validation.interfaces.IValidator import IValidator
11
12class MaxSmValidator:
13
14    __implements__ = IValidator
15
16    def __init__(self, name = '', maxsize=160, ):
17        self.name=name   
18        self.maxsize=maxsize
19       
20    def __call__(self, value, **kwargs):
21        sms_size=len(value)
22        if kwargs.has_key('maxsize'):
23            maxsize = kwargs.get('maxsize')
24
25        maxsize = self.maxsize   
26
27        if sms_size > maxsize:
28            return "Validation failed MaxSmValidator: Typed body is too large: %s (max %s)" % (sms_size, maxsize) 
29        else:
30            return True     
31       
Note: See TracBrowser for help on using the repository browser.