[gen] Added a validator for String fields, for validating Belgian NISS numbers.

This commit is contained in:
Gaetan Delannay 2013-07-10 18:05:06 +02:00
parent 369e41b43c
commit 05292356e7
2 changed files with 25 additions and 1 deletions

View file

@ -227,12 +227,19 @@ def normalizeString(s, usage='fileName'):
res = s
return res
# ------------------------------------------------------------------------------
def normalizeText(s):
'''Normalizes p_s: remove special chars, lowerizes it, etc, for indexing
purposes.'''
return normalizeString(s, usage='extractedText').strip().lower()
def keepDigits(s):
'''Returns string p_s whose non-number chars have been removed.'''
if s is None: return s
res = ''
for c in s:
if c.isdigit(): res += c
return res
# ------------------------------------------------------------------------------
def formatNumber(n, sep=',', precision=2, tsep=' '):
'''Returns a string representation of number p_n, which can be a float