From 166e268308d62a4a982c4048968e13700c4b70bc Mon Sep 17 00:00:00 2001 From: mdipierro Date: Fri, 10 Nov 2017 18:50:52 -0600 Subject: [PATCH] improved handling of regex and options field attributes --- gluon/dal.py | 10 +++++----- gluon/packages/dal | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gluon/dal.py b/gluon/dal.py index 0ebfd6a5..c794f612 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -32,7 +32,11 @@ def _default_validators(db, field): field_type, field_length = field.type, field.length requires = [] - if field_type in (('string', 'text', 'password')): + if field.options is not None and field.requires: + requires = validators.IS_IN_SET(field.options, multiple=field_type.startswith('list:')) + elif field.regex and not field.requires: + requires.append(validators.IS_REGEX(regex)) + elif field_type in (('string', 'text', 'password')): requires.append(validators.IS_LENGTH(field_length)) elif field_type == 'json': requires.append(validators.IS_EMPTY_OR(validators.IS_JSON())) @@ -50,10 +54,6 @@ def _default_validators(db, field): requires.append(validators.IS_TIME()) elif field_type == 'datetime': requires.append(validators.IS_DATETIME()) - elif field.options is not None: - requires = IS_IN_SET(field.options, multiple=field_type.startswith('list:')) - elif field.regex and not requires: - requires = IS_REGEX(regex) elif db and field_type.startswith('reference') and \ field_type.find('.') < 0 and \ field_type[10:] in db.tables: diff --git a/gluon/packages/dal b/gluon/packages/dal index d8631f68..c4ec44ca 160000 --- a/gluon/packages/dal +++ b/gluon/packages/dal @@ -1 +1 @@ -Subproject commit d8631f683cd374b274f7fe5caa0abf79b7fdc54c +Subproject commit c4ec44cac84c148121af340b27799b1c2f4e76e7