Permalink
Browse files

add documentation about setting the status code for validators. Fix #63

  • Loading branch information...
1 parent cae1f8b commit eb2b6e6fcd3ba9dd3e41ff77bc8367df3364edf3 @almet almet committed Jul 25, 2012
Showing with 11 additions and 1 deletion.
  1. +11 −1 docs/source/validation.rst
View
@@ -137,7 +137,6 @@ Let's take an example: we want to make sure the incoming request has an
if not 'X-Verified' in request.headers:
request.errors.add('header', 'X-Verified', 'You need to provied a token')
-
@foo.get(validators=has_paid)
def get_value(request):
"""Returns the value.
@@ -153,6 +152,17 @@ coming from the validation functions you are providing to put them in the
generated documentation. Refer to :doc:`sphinx` for more information about
documentation automatic generation.
+Changing the status code from validators
+----------------------------------------
+
+You also can change the status code returned from your validators. Here is an
+example of this::
+
+ def user_exists(request):
+ if not request.POST['userid'] in userids:
+ request.errors.add('body', 'userid', 'The user id does not exist')
+ request.errors.status = 404
+
Content-Type validation
=======================

0 comments on commit eb2b6e6

Please sign in to comment.