Skip to content

docs: say between, length and domain return ValidationError for bad arguments - #548

Open
spicysharkco wants to merge 1 commit into
python-validators:masterfrom
spicysharkco:docs/validator-raises
Open

spicysharkco wants to merge 1 commit into
python-validators:masterfrom
spicysharkco:docs/validator-raises

Conversation

@spicysharkco

Copy link
Copy Markdown

The Raises sections of between(), length() and domain() list ValueError, TypeError and UnicodeError. The validator decorator catches those and returns a ValidationError (with r_ve=True it raises one, which is not a ValueError), so an except ValueError clause never runs:

>>> import validators
>>> validators.length("something", min_val=-1)
ValidationError(func=length, args={'reason': 'Length cannot be negative. `min_val` is less than zero.', 'value': 'something', 'min_val': -1})

The length and between tests already expect the returned ValidationError. This changes only the docstrings: these cases move into Returns as their own ValidationError entries and the Raises sections go. No code changes.

…rguments

The Raises sections of between(), length() and domain() name ValueError,
TypeError and UnicodeError, but the validator decorator turns those into a
ValidationError, so an except clause for them never runs. List these cases
as ValidationError entries under Returns and drop the Raises sections. No
code changes.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant