Raise validation errors instead of returning False
masterBy default, validator functions return False if validation fails. To change this behavior so that a validators.utils.ValidationError is raised instead, you can use one of two methods:
Method 1: Environment Variable
Set the RAISE_VALIDATION_ERROR environment variable to True in your shell. This affects all validator calls in the process.
Method 2: Function Argument
Pass the keyword argument r_ve=True to the specific validator function call.
# Method 1: Using environment variable
$ export RAISE_VALIDATION_ERROR=True
$ python -c "from validators import url; print(url('https//bad_url'))"
# Method 2: Using r_ve=True argument
$ python -c "from validators.card import visa; print(visa('bad_visa_number', r_ve=True))"