strasbourg: add support for more validations
This commit is contained in:
parent
2c612ea14a
commit
8802f9eb07
|
@ -70,6 +70,11 @@ prefill = {
|
|||
}
|
||||
prefill_used = {}
|
||||
|
||||
regexes = {
|
||||
'Code postal': r'\d+',
|
||||
'Téléphone': r'\d+',
|
||||
}
|
||||
|
||||
|
||||
def process_children(node):
|
||||
global field_id, first_fieldset
|
||||
|
@ -159,11 +164,18 @@ def process_children(node):
|
|||
else:
|
||||
field.required = False
|
||||
|
||||
if validation is not None and validation.attrib.get('type') == 'validate-integer':
|
||||
field.validation = r'\d+'
|
||||
|
||||
if validation is not None and validation.attrib.get('type') == 'validate-custom':
|
||||
if validation.text:
|
||||
assert field_type == 'textinput'
|
||||
field.validation = fix_encoding(validation.text[1:-1])
|
||||
|
||||
for label in regexes:
|
||||
if field.label.startswith(label):
|
||||
field.validation = regexes.get(label)
|
||||
|
||||
if field_node.attrib.get('size'):
|
||||
size = field_node.attrib['size']
|
||||
assert size.endswith('px')
|
||||
|
|
Loading…
Reference in New Issue