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

Cross-validating Dictionary Values #264

Open
pugantsov opened this issue Jul 20, 2021 · 1 comment
Open

Cross-validating Dictionary Values #264

pugantsov opened this issue Jul 20, 2021 · 1 comment

Comments

@pugantsov
Copy link

pugantsov commented Jul 20, 2021

Hi there, I was wondering if it were possible to check two dictionary values against each other.

The use case I have is that I have a list of dictionaries which I'm checking which consist of two key-value pairs. Both of these types of values are lists and I want to check that both lists are the same length. Is it possible for me to do so?

@Stealthmate
Copy link

This should be possible using something like

Schema(
  And(
    {
      'foo': [str],
      'bar': [str]
    },
    lambda d: len(d['foo']) == len(d['bar'])
  )
)

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