Closed Yu-AnChen closed 2 years ago
Hi, thanks for using Yamale!
The error you're getting is from the YAML parser, not Yamale. The issue is here:
young person: include('person')
age: int(min=0, max=50)
The parser thinks you're trying to set young person
to a multi-line scaler value of include('person')\n age: int(min=0, max=50)
.
Instead, you can use yaml anchors to reference and extend a base mapping. For example:
cohort young: list(include('young person'))
cohort old: list(include('old person'))
---
person: &person
name: str()
is_active: bool()
young person:
<<: *person
age: int(min=0, max=50)
old person:
<<: *person
age: int(min=51)
Let me know if you have any other questions!
Thank you so much @mildebrandt for sharing the solution, I can confirm this is a YAML parsing issue and I didn't know yaml anchors syntax, it's super helpful! Closing this issue now :)
First of all, thanks for the great tool! I'm using it in my project and had some issues with the following case
I was hoping to create derived schemas (
young person
andold person
) from the "base schema" (person
), and the derived schemas would look like thesebut got an error
specifically, here are my questions -
Referencing point 4 in closed issue #8
Thanks!