Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve colander schema error message handling #47

Merged
merged 2 commits into from Apr 3, 2012
Merged

Improve colander schema error message handling #47

merged 2 commits into from Apr 3, 2012

Conversation

ymage
Copy link

@ymage ymage commented Apr 3, 2012

Colander error message placeholder were not replaced.

Before :
${val} is greater than ${max}
After :
5 is greater than 3

@@ -34,14 +34,14 @@ def _validate_fields(location, data):
request.errors.add(location, attr.name,
"%s is missing" % attr.name)
else:
if not attr.name in data:
request.validated[attr.name] = attr.missing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not remove the request.validated[attr.name] = attr.missing, it's part of the API and shound not be changed. Is there any reason why you're removing it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my point of view, the SchemaNode deserialize() method does the same thing in the right way.
"missing" case is matched with deserialized = attr.deserialize(None)

Moreover, deserialize() populate the error message with values.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, right. Works for me then, sounds a better way to deal with validation errors. Sounds weird to put something missing in "validated" anyway.

Thanks again for the contribution.

@almet
Copy link
Contributor

almet commented Apr 3, 2012

Thanks for the pull request, looks good to me appart from the minor nitpick I added.

almet added a commit that referenced this pull request Apr 3, 2012
Improve colander schema error message handling
@almet almet merged commit d3b6bf1 into Cornices:master Apr 3, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants