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

feature request: use different value validators selected by key validators #7

Open
jremmet opened this issue Oct 4, 2021 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@jremmet
Copy link

jremmet commented Oct 4, 2021

Usecase: a dict with keys where the name shows which kind of validator should be used to validate it.
e.g.

{
    "val_foo": 1
    "val_bar": 2
    "str_foo: "hello"
    "str_bar": "world"
}

To validate this directly something like this would be nice:

Dict(extra=[
    (Str(pattern="val_.*"), Int()),
    (Str(pattern = "str_.*), Str())
])

I didn't find a way to avoid link the key and value validator. Splitting this up via OneOf fails if both kinds of keys are present.

@kr41 kr41 added the enhancement New feature or request label Oct 5, 2021
@kr41
Copy link
Member

kr41 commented Oct 5, 2021

Good point! However, I would like to implement more general solution.

@kr41 kr41 added this to the 0.9 milestone Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants