-
Notifications
You must be signed in to change notification settings - Fork 9
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
Extending custom validations #100
Comments
And do not include hashes into docs requirements, as they are not installable in Read The Docs :( Issue: #100
Hi, There is a async def add_comment(request: web.Request) -> web.Response:
"""Add comment, but only if text do not contain stop words"""
# Get validated data from request, this is a shortcut to,
#
# .. code-block:: python
#
# context = get_openapi_context(request)
# data = context.data
#
# In that moment request data **already** validated via OpenAPI Schema
data = get_validated_data(request)
# Now call custom validator to check whether comment text contains stop words
if has_stop_words(data["text"]):
# If text contain stop words - do not allow user add a comment
raise ValidationError.from_dict(body={"text": "Please use kind language"})
... I just updated docs to contain at least ValidationError API docs and will provide more docs & examples later. As of Hope you find my answers helpful, if not I will be happy to provide more information on the topic. |
Thanks a lot!. |
Features: --------- - [#133] (**openapi**) Allow to pass kwargs to validate email func (#135) - [#100, #132] (**openapi**) Improve validation errors (#142) Other: ------ - Update dev Python version to 3.9.1 (#136) - (**deps-dev**) bump pytest from 6.1.2 to 6.2.1 (#131) - (**deps-dev**) bump coverage from 5.3 to 5.3.1 (#130) - (**deps**) bump actions/checkout from v2.3.3 to v2.3.4 (#141) - (**deps**) bump actions/cache from v2.1.2 to v2.1.3 (#138) - (**deps**) bump actions/setup-python from v2.1.4 to v2.2.1 (#139) - (**deps**) bump peter-evans/create-pull-request from v3.4.1 to v3.6.0 (#140) - (**deps**) bump tibdex/github-app-token from v1.1.0 to v1.3 (#137)
Features: --------- - [#133] (**openapi**) Allow to pass kwargs to validate email func (#135) - [#100, #132] (**openapi**) Improve validation errors (#142) Other: ------ - Update dev Python version to 3.9.1 (#136) - (**deps-dev**) bump pytest from 6.1.2 to 6.2.1 (#131) - (**deps-dev**) bump coverage from 5.3 to 5.3.1 (#130) - (**deps**) bump actions/checkout from v2.3.3 to v2.3.4 (#141) - (**deps**) bump actions/cache from v2.1.2 to v2.1.3 (#138) - (**deps**) bump actions/setup-python from v2.1.4 to v2.2.1 (#139) - (**deps**) bump peter-evans/create-pull-request from v3.4.1 to v3.6.0 (#140) - (**deps**) bump tibdex/github-app-token from v1.1.0 to v1.3 (#137) Co-authored-by: playpauseandstop <playpauseandstop@users.noreply.github.com>
Hello,
I cant seem to figure out how to extend Validations with custom validations.
Whenever I raise something, i (default?) error.
Example (for someplicity)
I end up with this error:
{"detail": [{"loc": ["response", 0], "message": "'detail' is not of type object"}]}
I assume that whenever i use
with openapi_context(request) as context:
i get into the reponse layer.Sadly i cant figure out how to combine it with my extra validations
The text was updated successfully, but these errors were encountered: