Skip to content

Conversation

@minboost
Copy link
Owner

No description provided.

hltbra and others added 30 commits July 7, 2016 16:06
Add validate_schema decorator
~20 backwards-compatible upgrades since the last release - the time is ripe! Minor version bump is appropriate as per semver.org standard.
Remove setup_requires from setup.py
Invert Range tests so nan is excluded
Fix Exact Sequence to Match Lengths
Empty lists are now regarded as is. If a free-form list is needed, use 'list'.
Fixes #204: Making Path validators resilient to None.
Introducing decorator that is able to validate input arguments and return value
of the decorated function.

Before calling the wrapped function, the validators specified in the
decorator's argument list will be tested against the values passed at
the function call.

```
@validate_schema(arg1=int, arg2=int)
def foo(arg1, arg2):
  return arg1 * arg2
```

After calling the function with the validated arguments, schema
specified in `RETURNS_KEY` (currently `__return__`) will be applied
against the output.

```
@validate_schema(arg1=int, arg2=int, __returns__=int)
def foo(arg1, arg2):
  return arg1 * arg2
```

See more in the related test cases.

Signed-off-by: Gergő Nagy <grigori.grant@gmail.com>
Handle non-subscriptable path in humanize_error
antoni-szych-rtbhouse and others added 30 commits December 14, 2023 04:39
…tox (#501)

* feat: add python 3.11 to github workflow tox matrix, remove 3.7 from tox

* run flake8 and mypy on py311

* add py311 to package metadata
…ata (#502)

* feat: add python 3.12 to github workflow tox matrix and package metadata

* bump minimal python requirement in setup.py
python 3.8 goes EOL in 2024-10
* Fix vol.Remove not removing keys

fixes a regression from #479
blocks #479

* add test
* Remove Maybe validator typing

* Use Schemable as validator type
* Add comprehensive tests for humanize.py module to improve coverage from 71% to 100%

- Add tests for _nested_getitem error handling (KeyError, IndexError, TypeError)
- Add tests for humanize_error with long error message truncation
- Add tests for validate_with_humanized_errors success and failure cases
- Add tests for edge cases with None data and multiple validation errors
- Improve overall test coverage from 89% to 90%

This addresses the missing coverage in humanize.py lines 19-22, 45, and 54-57.

* Fix import sorting with isort
* Feature: Support requiring anyOf a list of keys

This adds a new feature to Voluptuous, which is somewhat akin to what json-schema does with the special key `anyOf`.

`Schema({Required(Any('color', 'temperature', 'brightness')): str})` will validate that AT LEAST ONE of these three values is present. That doesn't preclude any individual validation on each of those fields to still apply.
That means that in the above example, if `color` is present, brightness doesn't need to be present. But if brightness is present, all other validations of brightness (like checking that its value is a number between 0 and 100) still apply.

* Simplify tests

* Format stuff like black wants it
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.