Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial validation with @validate? #296

Closed
AndreaCrotti opened this issue Jul 4, 2017 · 2 comments
Closed

Partial validation with @validate? #296

AndreaCrotti opened this issue Jul 4, 2017 · 2 comments

Comments

@AndreaCrotti
Copy link
Contributor

I was a bit surprised that the following snippet doesn't work

import voluptuous as V

API_SCHEMA = V.Schema({
    V.Required('uri'): str,
}, extra=V.ALLOW_EXTRA)

print(API_SCHEMA({'uri': 'hello', 'other': 'hello'}))


@V.validate(data=API_SCHEMA)
def func(a, data):
    print(data)


func(10, {'uri': 'hello', 'other': 'hello'})

And it gives this error:

    raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: extra keys not allowed @ data['a']

I can't find any flag (or tests supporting the idea that there is a way) to do this kind of partial validation of argument types.
Is it not possible on purpose for some reason?
Thanks!

@tusharmakkar08
Copy link
Collaborator

Hey @AndreaCrotti

This looks like a bug. Thanks for reporting it out.
Will work on it soon. Meanwhile, if you are interested you can open a PR for the same.

Regards,
TM

@tusharmakkar08
Copy link
Collaborator

Closed via #303

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

No branches or pull requests

2 participants