From d5c318eaa680303afb2dee248a16b30d05b1dd43 Mon Sep 17 00:00:00 2001 From: Garrett Primm <103901383+garrettprimm@users.noreply.github.com> Date: Fri, 30 Dec 2022 16:39:34 -0600 Subject: [PATCH] Update "User-friendly error reporting" example Updating the "User-friendly error reporting" example to reflect the feature implemented in the following PR https://github.com/keleshev/schema/pull/107/files. --- README.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 0c70c0b..8b6baa6 100644 --- a/README.rst +++ b/README.rst @@ -456,10 +456,10 @@ instead of a built-in one. .. code:: python - >>> Schema(Use(int, error='Invalid year')).validate('XVII') + >>> Schema(Use(int, error='Invalid year {}')).validate('XVII') Traceback (most recent call last): ... - schema.SchemaError: Invalid year + schema.SchemaError: Invalid year XVII You can see all errors that occurred by accessing exception's ``exc.autos`` for auto-generated error messages, and ``exc.errors`` for errors @@ -469,6 +469,7 @@ You can exit with ``sys.exit(exc.code)`` if you want to show the messages to the user without traceback. ``error`` messages are given precedence in that case. + A JSON API example -------------------------------------------------------------------------------