-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
209 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Install and Use | ||
|
||
## Installation | ||
|
||
Execute the following command: | ||
|
||
```text | ||
pip install validators | ||
``` | ||
|
||
> It's preferable to use `pip` within a virtual environment. | ||
## Usage | ||
|
||
```python | ||
import validators | ||
print(validators.email('[email protected]')) | ||
``` | ||
|
||
### To raise validation error | ||
|
||
1. Either set the environment variable `RAISE_VALIDATION_ERROR` to `True` | ||
|
||
```console | ||
$ export RAISE_VALIDATION_ERROR=True | ||
$ python -c "from validators import url; print(url('https//bad_url'))" | ||
Traceback (most recent call last): | ||
File "<string>", line 1, in <module> | ||
File "/path/to/lib/validators/utils.py", line 87, in wrapper | ||
raise ValidationError(func, _func_args_as_dict(func, *args, **kwargs)) | ||
validators.utils.ValidationError: ValidationError(func=url, args={'value': 'https//bad_url'}) | ||
``` | ||
|
||
2. Or pass `r_ve=True` to each caller function: | ||
|
||
```console | ||
$ python -c "from validators.card import visa; print(visa('bad_visa_number', r_ve=True))" | ||
Traceback (most recent call last): | ||
File "<string>", line 1, in <module> | ||
File "/path/to/lib/validators/utils.py", line 87, in wrapper | ||
raise ValidationError(func, _func_args_as_dict(func, *args, **kwargs)) | ||
validators.utils.ValidationError: ValidationError(func=visa, args={'value': 'bad_visa_number'}) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
Install and Use | ||
=============== | ||
|
||
Installation | ||
------------ | ||
|
||
Execute the following command: | ||
|
||
.. code:: text | ||
pip install validators | ||
.. | ||
It's preferable to use ``pip`` within a virtual environment. | ||
|
||
Usage | ||
----- | ||
|
||
.. code:: python | ||
import validators | ||
print(validators.email('[email protected]')) | ||
To raise validation error | ||
~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
1. Either set the environment variable ``RAISE_VALIDATION_ERROR`` to | ||
``True`` | ||
|
||
.. code:: console | ||
$ export RAISE_VALIDATION_ERROR=True | ||
$ python -c "from validators import url; print(url('https//bad_url'))" | ||
Traceback (most recent call last): | ||
File "<string>", line 1, in <module> | ||
File "/path/to/lib/validators/utils.py", line 87, in wrapper | ||
raise ValidationError(func, _func_args_as_dict(func, *args, **kwargs)) | ||
validators.utils.ValidationError: ValidationError(func=url, args={'value': 'https//bad_url'}) | ||
2. Or pass ``r_ve=True`` to each caller function: | ||
|
||
.. code:: console | ||
$ python -c "from validators.card import visa; print(visa('bad_visa_number', r_ve=True))" | ||
Traceback (most recent call last): | ||
File "<string>", line 1, in <module> | ||
File "/path/to/lib/validators/utils.py", line 87, in wrapper | ||
raise ValidationError(func, _func_args_as_dict(func, *args, **kwargs)) | ||
validators.utils.ValidationError: ValidationError(func=visa, args={'value': 'bad_visa_number'}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters