Skip to content

Commit

Permalink
Merge pull request #434 from elatomo/fix-reqparse-docs
Browse files Browse the repository at this point in the history
Fix custom type docs on "Intermediate usage" and docstring
  • Loading branch information
joshfriend committed May 3, 2015
2 parents 754017c + 45b4f31 commit 0cbe85b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions docs/intermediate-usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ exercise a larger amount of options. We'll define a resource named "User". ::
from flask_restful import fields, marshal_with, reqparse, Resource

def email(email_str):
""" return True if email_str is a valid email """
if valid_email(email):
return True
"""Return email_str if valid, raise an exception in other case."""
if valid_email(email_str):
return email_str
else:
raise ValidationError("{} is not a valid email")
raise ValueError('{} is not a valid email'.format(email_str))

post_parser = reqparse.RequestParser()
post_parser.add_argument(
Expand Down Expand Up @@ -183,9 +183,9 @@ of 'the username field is required'. ::
)

The ``email`` field has a custom type of ``email``. A few lines earlier we
defined an ``email`` function that takes a string and returns ``True`` if the
type is valid, else it raises a ``ValidationError`` exclaiming that the
email type was invalid. ::
defined an ``email`` function that takes a string and returns it if the type is
valid, else it raises an exception, exclaiming that the email type was
invalid. ::

post_parser.add_argument(
'user_priority', dest='user_priority',
Expand Down
4 changes: 2 additions & 2 deletions flask_restful/reqparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Argument(object):
:param ignore: Whether to ignore cases where the argument fails type
conversion
:param type: The type to which the request argument should be
converted. If a type raises a ValidationError, the message in the
converted. If a type raises an exception, the message in the
error will be returned in the response. Defaults to :class:`unicode`
in python2 and :class:`str` in python3.
:param location: The attributes of the :class:`flask.Request` object
Expand All @@ -56,7 +56,7 @@ class Argument(object):
:param choices: A container of the allowable values for the argument.
:param help: A brief description of the argument, returned in the
response when the argument is invalid with the name of the argument and
the message passed to a ValidationError raised by a type converter.
the message passed to any exception raised by a type converter.
:param bool case_sensitive: Whether the arguments in the request are
case sensitive or not
:param bool store_missing: Whether the arguments default value should
Expand Down

0 comments on commit 0cbe85b

Please sign in to comment.