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.

validate including the key values in another list

See original GitHub issue

I’m looking to ways to validate that certain keys are included in a predefined list, an example can be

  - 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

  - 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:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

modsaidcommented, Jan 26, 2021

Thank you @mildebrandt @mechie 🙏

mechiecommented, Oct 18, 2020

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:

students: list(include('student'))
  name: str()
  teacher: enum('Mike', 'Anna', 'Smith')
students: list(include('student'))
  name: str()
  teacher: enum(

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:

  • Expand or inherit from the Enum validator to accept include() statements that correspond to lists of primitives (this sounds useful in general).
  • Override multiple places (probably Schema._validate, and adding a custom validator) to handle loading in the teachers from the data before/during validation.
  • Write a script that runs before yamale and fills in the teacher enum using a list from the data (which could be validated beforehand, something like yamale(doc, first schema) -> script(doc, incomplete second schema) -> yamale(doc, second schema)).
Read more comments on GitHub >

github_iconTop 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 >

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 Post

No results found

github_iconTop Related Hashnode Post

No results found