Closed Dejv456 closed 5 years ago
Hi, there's a PR in review that may allow for this: https://github.com/23andMe/Yamale/pull/60
This is available in version 2.0.
Hi @mildebrandt, this may be a dumb question but... Could you please explain how to do this now? I couldn't spot this scenario in the readme, and I tried writing the schema like
str(): include('profile')
---
profile:
type: int()
option: str()
but just get
Error validating data data.yaml with schema schema.yaml
str(): Required field missing
I tried searching the repo with words like "custom" or "dynamic" but the former is a common word otherwise and the latter is nowhere to be found... Thanks for your help.
Hi @Phidica, thanks for your interest in Yamale.
For this, it seemed that @Dejv456 didn't want to validate the key per se, but wanted the ability to use anything as the key at the root of the document. To achieve that, we let map()
be defined at the top level of the schema, like this:
map(include('user'))
---
user:
name: str()
age: int()
Then the following yaml would validate as successful:
bob:
name: Bob Ross
age: 52
If you want actual validation for the keys of a map, that was briefly discussed in issue #53. We would welcome a PR that added the functionality outlined in comment https://github.com/23andMe/Yamale/issues/53#issuecomment-516957631
Ah, okay, thank you for the advice :)
Hello,
is it possible to validate custom key ('abc' or 'bcd' or whatever str()) as below:
Data:
Schema: