source: products/ShortMessage/tags/0.1.3/validators.py @ 1591

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

Building directory structure

File size: 606 bytes
Line 
1from Products.validation.interfaces.IValidator import IValidator
2
3class MaxSmValidator:
4    """validator for short message"""
5
6    __implements__ = IValidator
7
8    def __init__(self, name = '', maxsize=160, ):
9        self.name=name   
10        self.maxsize=maxsize
11       
12    def __call__(self, value, **kwargs):
13        sms_size=len(value)
14        if kwargs.has_key('maxsize'):
15            maxsize = kwargs.get('maxsize')
16
17        maxsize = self.maxsize   
18
19        if sms_size > maxsize:
20            return "Validation failed MaxSmValidator: Typed body is too large: %s (max %s)" % (sms_size, maxsize) 
21        else:
22            return True     
23       
Note: See TracBrowser for help on using the repository browser.