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

Loading…
Cancel
Save