是否有YAML的架构验证语言?我用谷歌搜索,但找不到任何有用的东西.
XSD格式之类的东西,使用语言本身来描述模式,在我的情况下是最好的选择.
我有一个配置信息的字典:
my_conf = {
'version': 1,
'info': {
'conf_one': 2.5,
'conf_two': 'foo',
'conf_three': False,
'optional_conf': 'bar'
}
}
Run Code Online (Sandbox Code Playgroud)
我想检查字典是否遵循我需要的结构.
我正在寻找这样的东西:
conf_structure = {
'version': int,
'info': {
'conf_one': float,
'conf_two': str,
'conf_three': bool
}
}
is_ok = check_structure(conf_structure, my_conf)
Run Code Online (Sandbox Code Playgroud)
是否有任何解决方案可以解决此问题或任何可以使实施check_structure
更容易的库?