diff --git a/README.md b/README.md index f8ee14f348bbbfa0739651a05ba43ccbde9e1ec4..e674dced1c1f9c0bee1bed475f9af6727e5ede4b 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ Parameter | Type | Default | Description `ckanext.odsh.copy_remote_resources` | `boolean` | `False` | Indicates whether remote resources should be copied when creating a resource. `ckanext.odsh.lenient_with` | `string` | Empty string | Comma seperated list of organization IDs for which certain validations should be more lenient, e.g., `09871195-cd0a-4767-9396-276404c940d9,6389d8d9-4eed-472f-9220-4cc2dd82fb90`. `ckanext.odsh.min_tag_length` | `integer` | `2` | Minimum characters allowed for tag length. -`ckanext.odsh.max_tag_length` | `integer` | `100` | Maximum characters allowed for tag length. +`ckanext.odsh.max_tag_length` | `integer` | `100` | Maximum characters allowed for tag length. (Maximum value: 100) `ckanext.odsh.testuser` | `string` | `None` | Name of user for testing. `ckanext.odsh.testuserpass` | `string` | `None` | Password of user for testing. diff --git a/ckanext/odsh/tests_wip/test_validation.py b/ckanext/odsh/tests_wip/test_validation.py index f21ee4466e986530a5206ba0baf0d4121d4206eb..55136e2df2dd28ebfde6be6929aafd160a06e152 100644 --- a/ckanext/odsh/tests_wip/test_validation.py +++ b/ckanext/odsh/tests_wip/test_validation.py @@ -119,6 +119,8 @@ def test_tag_name_validator_valid(): def test_tag_length_validator_invalid(): min = int(toolkit.config.get('ckanext.odsh.min_tag_length',2)) max = int(toolkit.config.get('ckanext.odsh.max_tag_length',100)) + if max_tag_length > 100: + max_tag_length = 100 length = round((min + max) / 2) test_string = _create_test_string(length) with pytest.raises(Exception): diff --git a/ckanext/odsh/validation.py b/ckanext/odsh/validation.py index 0ad3d7fe1b2a45cb07c48a75755cd057181f33e9..6c14d7a677da84065452518b20a4b71403469cc3 100644 --- a/ckanext/odsh/validation.py +++ b/ckanext/odsh/validation.py @@ -316,9 +316,12 @@ def tag_length_validator(value, context): min_tag_length = int(tk.config.get('ckanext.odsh.min_tag_length',2)) max_tag_length = int(tk.config.get('ckanext.odsh.max_tag_length',100)) + if max_tag_length > 100: + max_tag_length = 100 + if len(value) < min_tag_length: raise toolkit.Invalid( - _('Tag "%s" length is less than minimum %s') % (value, max_tag_length) + _('Tag "%s" length is less than minimum %s') % (value, min_tag_length) ) if len(value) > max_tag_length: raise toolkit.Invalid(