mirror of
https://github.com/yweber/lodel2.git
synced 2025-10-21 16:49:02 +02:00
Added unit tests for the Regex datahandler
This commit is contained in:
parent
3299dc549a
commit
9ab3293538
1 changed files with 2 additions and 1 deletions
|
@ -2,6 +2,7 @@
|
||||||
import warnings
|
import warnings
|
||||||
import inspect
|
import inspect
|
||||||
from lodel.leapi.datahandlers.datas_base import *
|
from lodel.leapi.datahandlers.datas_base import *
|
||||||
|
import re
|
||||||
|
|
||||||
##@brief Data field designed to handle formated strings
|
##@brief Data field designed to handle formated strings
|
||||||
class FormatString(Varchar):
|
class FormatString(Varchar):
|
||||||
|
@ -46,7 +47,7 @@ max_length and regex'
|
||||||
|
|
||||||
def _check_data_value(self, value):
|
def _check_data_value(self, value):
|
||||||
error = None
|
error = None
|
||||||
if not self.compiled_re.match(value):
|
if not self.compiled_re.match(value) or len(value) > self.max_length:
|
||||||
value = ''
|
value = ''
|
||||||
msg = '"%s" doesn\'t match the regex "%s"' % (value, self.regex)
|
msg = '"%s" doesn\'t match the regex "%s"' % (value, self.regex)
|
||||||
error = TypeError(msg)
|
error = TypeError(msg)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue