Skip to content

Commit

Permalink
Fixed doc hyperlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
sg495 committed Jan 30, 2024
1 parent 9f8f5b4 commit 46159b7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ You can install the latest release from `PyPI <https://pypi.org/project/typing-v
Usage
-----

The core functionality of this library is provided by the `validate` function:
The core functionality of this library is provided by the `validate <https://typing-validation.readthedocs.io/en/latest/api/typing_validation.validation.html#typing_validation.validation.validate>`_ function:


>>> from typing_validation import validate

The `validate` function is invoked with a value and a type as its arguments and it returns nothing when the given value is valid for the given type:
The `validate <https://typing-validation.readthedocs.io/en/latest/api/typing_validation.validation.html#typing_validation.validation.validate>`_ function is invoked with a value and a type as its arguments and it returns nothing when the given value is valid for the given type:

>>> validate(12, int)
True # no error raised => 12 is a valid int

If the value is invalid for the given type, the `validate` function raises a `TypeError`:
If the value is invalid for the given type, the `validate <https://typing-validation.readthedocs.io/en/latest/api/typing_validation.validation.html#typing_validation.validation.validate>`_ function raises a `TypeError <https://docs.python.org/3/library/exceptions.html#TypeError>`_:

>>> validate(12, str)
TypeError: Runtime validation error raised by validate(val, t), details below.
Expand All @@ -72,13 +72,13 @@ For type list[int], invalid value at idx: 2
For type <class 'int'>, invalid value: 'hi'


The function `is_valid` is a variant of the `validate` function which returns `False` in case of validation failure, instead of raising `TypeError`:
The function `is_valid` is a variant of the `validate <https://typing-validation.readthedocs.io/en/latest/api/typing_validation.validation.html#typing_validation.validation.validate>`_ function which returns `False` in case of validation failure, instead of raising `TypeError <https://docs.python.org/3/library/exceptions.html#TypeError>`_:

>>> from typing_validation import is_valid
>>> is_valid([0, 1, "hi"], list[int])
False

The function `latest_validation_failure` can be used to access detailed information immediately after a failure:
The function `latest_validation_failure <https://typing-validation.readthedocs.io/en/latest/api/typing_validation.validation.html#typing_validation.validation_failure.latest_validation_failure>` can be used to access detailed information immediately after a failure:

>>> from typing_validation import latest_validation_failure
>>> is_valid([0, 1, "hi"], list[int])
Expand All @@ -89,7 +89,7 @@ Runtime validation error raised by validate(val, t), details below.
For type list[int], invalid value at idx: 2
For type <class 'int'>, invalid value: 'hi'

Please note that `latest_validation_failure` clears the internal failure logs after returning the latest failure, so the latter must be manually stored if it needs to be accessed multiple times.
Please note that `latest_validation_failure <https://typing-validation.readthedocs.io/en/latest/api/typing_validation.validation.html#typing_validation.validation_failure.latest_validation_failure>` clears the internal failure logs after returning the latest failure, so the latter must be manually stored if it needs to be accessed multiple times.


API
Expand Down
4 changes: 2 additions & 2 deletions docs/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ For type list[typing.Union[typing.Collection[int], dict[str, str]]], invalid val
For member type dict[str, str], invalid value at key: 'hi'
For type <class 'str'>, invalid value: 0

The function :func:`~typing_validation.validation.is_valid` is a variant of the :func:`~typing_validation.validation.validate` function which returns :obj:`False` in case of validation failure, instead of raising `TypeError`:
The function :func:`~typing_validation.validation.is_valid` is a variant of the :func:`~typing_validation.validation.validate` function which returns :obj:`False` in case of validation failure, instead of raising :exc:`TypeError`:

>>> from typing_validation import is_valid
>>> is_valid([0, 1, "hi"], list[int])
False

The function `latest_validation_failure` can be used to access detailed information immediately after a failure:
The function :func:`~typing_validation.validation_failure.latest_validation_failure` can be used to access detailed information immediately after a failure:

>>> from typing_validation import latest_validation_failure
>>> is_valid([0, 1, "hi"], list[int])
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ For type list[typing.Union[typing.Collection[int], dict[str, str]]], invalid val
For member type dict[str, str], invalid value at key: 'hi'
For type <class 'str'>, invalid value: 0

The function :func:`~typing_validation.validation.is_valid` is a variant of the `validate` function which returns :obj:`False` in case of validation failure, instead of raising `TypeError`:
The function :func:`~typing_validation.validation.is_valid` is a variant of the :func:`~typing_validation.validation.validate` function which returns :obj:`False` in case of validation failure, instead of raising :obj:`TypeError`:

>>> from typing_validation import is_valid
>>> is_valid([0, 1, "hi"], list[int])
Expand Down

0 comments on commit 46159b7

Please sign in to comment.