validate including the key values in another list
See original GitHub issueIssue Description
I’m looking to ways to validate that certain keys are included in a predefined list, an example can be
---
teachers:
- Mike
- Anna
- Smith
And I want to add students where each student need to have a teacher str value which should be part of the given list above
---
students:
- name: studentA
teacher: Mike
- name: StudentB
teacher: NonExistingTeacher
going through the docs and examples it is not clear if this is even possible to do using yamale
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Validate all values in a list of strings are in another list - MSDN
I want to make sure all the values in the above list are contained within a list of columns I pull from the...
Read more >Easy Steps Excel Dependent Drop Down List Data Validation
Easy steps for Excel dependent drop-down list. Conditional data validation based on other cell, like Region and City lists.
Read more >Check if list<t> contains any of another list - Stack Overflow
I want to iterate over the parameter list and check if the source property is equal to any of the myStrings array. I...
Read more >Data validation in Excel: how to add, use and remove - Ablebits
Select one or more cells to validate, go to the Data tab > Data Tools group, and click the Data Validation button. You...
Read more >Cerberus Usage — Python data validation library
If all keys should share the same validation rules you probably want to use valueschema instead. schema (list)¶. You can also use this...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thank you @mildebrandt @mechie 🙏
If the list of teachers can be defined within the schema, then you could rewrite it as an enum (e.g.
teacher: enum('Mike', 'Anna', 'Smith')
), that will work with yamale as-is.So the schema would look like one of the two below:
Otherwise (if it must be formatted as a list, and/or will be provided as part of the file to validate) there’s a lot of routes available, but they’d require tinkering:
include()
statements that correspond to lists of primitives (this sounds useful in general).Schema._validate
, and adding a custom validator) to handle loading in the teachers from the data before/during validation.yamale(doc, first schema) -> script(doc, incomplete second schema) -> yamale(doc, second schema)
).