Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

YAML Schema Validation?

Is there a schema validation language for YAML? I've googled but couldn't find anything useful.

Something like XSD format, using the language itself to describe the schema, would be the best choice in my case.

like image 407
Klaim Avatar asked Feb 20 '11 21:02

Klaim


People also ask

Does YAML has schema?

Providing a schema describing the structure of a YAML file type is possible. You might not find the specification easily because it relies on the JSON Schema specifications.

Can JSON schema be used with YAML?

JSON schema in YAML is considered as the common denominator of most modern computer languages. It allows parsing JSON files. It is strongly recommended in YAML that other schemas should be considered on JSON schema. The primary reason for this is that it includes key value combination which are user friendly.

How do I validate a YAML file in Python?

Validate the YAML with its corresponding schema for basic data type check. Custom validations like IP address, random strings can be added in schema.

What is Yaml validator?

YAML Validator works well on Windows, MAC, Linux, Chrome, Firefox, Edge, and Safari. This YAML Linter helps a developer who works with JSON data to test and verify.


1 Answers

JSON Schema can be used with most YAML documents resulting in a more portable and better documented solution than Rx or Kwalify. JSON Schema is the only of the three for which I have been able to find editor support.

More information on using YAML and JSON Schema including tools and editor support is tracked on this page. At the time of writing, there is editor support in Visual Studio Code and a command-line based validation tool available via npm.


Full Disclosure: I authored the web site linked above to try to make the application of JSON Schema to YAML more discoverable. I also wrote an editor extension for VS Code that has since been superseded by the RedHat extension linked above.

like image 155
vossad01 Avatar answered Oct 22 '22 03:10

vossad01