question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Validating a list of "dictionaries"

See original GitHub issue

I have a schema that works out very well, but there’s one issue: one part of my YAML files can include a key where the values are a list of dictionary values (ie, each element is a key/value pair. How would I go about validating this?

The most I know is that I need a list (since the root key is going to be a list), but the values of each list are dictionaries which doesn’t seem to have a validator available atm?

EDIT: I think the correct method is list(map(str(), key=str()), required=False, none=True), is this correct?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
mildebrandtcommented, Dec 5, 2020

Hi, thanks for using Yamale! What you have will work just fine. If you need to constrain the keys of the map further, you can use the regex validator instead of the str validator.

And thanks @mechie for jumping in to help answer questions.

0reactions
mildebrandtcommented, Dec 6, 2021

@ilia-wolke7 Let’s keep the conversation for your issue in https://github.com/23andMe/Yamale/issues/184. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to validate a list of dictionaries using jsonschema with ...
Basically, you're trying to describe a list that can contain any number of two different kinds of objects. Here's an example of use:...
Read more >
python - Validating a list of dictionaries of names and tags
In the above, name and tags are the keys of our dictionaries. ... Next, to validate our top-level list, we need to instantiate...
Read more >
How can I correctly validate a list of dictionaries? #1843 - GitHub
I have a function that returns a list of dictionaries, and want the output of the function to be passed as a parameter...
Read more >
FormEncode Validation — FormEncode 0.0.0 documentation
Validator includes the module formencode.variabledecode , which allows you to encode nested dictionary and list structures into a flat dictionary. To do this...
Read more >
Do Not Use If-Else For Validating Data Objects In Python ...
Python validating dictionary, JSON and data object without if-else condition but ... forbidden the value must not be in a pre-defined list ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found