Browse Source

Added unit tests for the Regex datahandler

Roland Haroutiounian 8 years ago
parent
commit
9ab3293538
1 changed files with 2 additions and 1 deletions
  1. 2
    1
      lodel/leapi/datahandlers/datas.py

+ 2
- 1
lodel/leapi/datahandlers/datas.py View File

2
 import warnings
2
 import warnings
3
 import inspect
3
 import inspect
4
 from lodel.leapi.datahandlers.datas_base import *
4
 from lodel.leapi.datahandlers.datas_base import *
5
+import re
5
 
6
 
6
 ##@brief Data field designed to handle formated strings
7
 ##@brief Data field designed to handle formated strings
7
 class FormatString(Varchar):
8
 class FormatString(Varchar):
46
 
47
 
47
     def _check_data_value(self, value):
48
     def _check_data_value(self, value):
48
         error = None
49
         error = None
49
-        if not self.compiled_re.match(value):
50
+        if not self.compiled_re.match(value) or len(value) > self.max_length:
50
             value = ''
51
             value = ''
51
             msg = '"%s" doesn\'t match the regex "%s"' % (value, self.regex)
52
             msg = '"%s" doesn\'t match the regex "%s"' % (value, self.regex)
52
             error = TypeError(msg)
53
             error = TypeError(msg)

Loading…
Cancel
Save