Validating a yaml document in python

前端 未结 10 2198
谎友^
谎友^ 2020-12-24 04:24

One of the benefits of XML is being able to validate a document against an XSD. YAML doesn\'t have this feature, so how can I validate that the YAML document I open is in th

10条回答
  •  天涯浪人
    2020-12-24 05:11

    These look good. The yaml parser can handle the syntax erorrs, and one of these libraries can validate the data structures.

    • http://pypi.python.org/pypi/voluptuous/ (I've tried this one, it is decent, if a bit sparse.)
    • http://discorporate.us/projects/flatland/ (not clear how to validate files at first glance)

提交回复
热议问题