Skip to content

Commit

Permalink
[#621] Move extras_validation into __before
Browse files Browse the repository at this point in the history
This fixes an issue where creating a new resource would crash in
validation if there was a custom field (using convert_to/from_extras)
with a name that sorted after extras validation alphabetically. Fixes #621.
  • Loading branch information
Sean Hammond authored and amercader committed Apr 17, 2013
1 parent 11e808c commit d8362a1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ckan/logic/schema.py
Expand Up @@ -116,6 +116,7 @@ def default_create_tag_schema():

def default_create_package_schema():
schema = {
'__before': [duplicate_extras_key, ignore],
'id': [empty],
'revision_id': [ignore],
'name': [not_empty, unicode, name_validator, package_name_validator],
Expand All @@ -139,7 +140,6 @@ def default_create_package_schema():
'tags': default_tags_schema(),
'tag_string': [ignore_missing, tag_string_convert],
'extras': default_extras_schema(),
'extras_validation': [duplicate_extras_key, ignore],
'save': [ignore],
'return_to': [ignore],
'relationships_as_object': default_relationship_schema(),
Expand Down
2 changes: 1 addition & 1 deletion ckan/logic/validators.py
Expand Up @@ -313,7 +313,7 @@ def duplicate_extras_key(key, data, errors, context):
for extra_key in set(extras_keys):
extras_keys.remove(extra_key)
if extras_keys:
errors[key].append(_('Duplicate key "%s"') % extras_keys[0])
errors['extras_validation'].append(_('Duplicate key "%s"') % extras_keys[0])

def group_name_validator(key, data, errors, context):
model = context['model']
Expand Down

0 comments on commit d8362a1

Please sign in to comment.