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.
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.
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.
Validate the YAML with its corresponding schema for basic data type check. Custom validations like IP address, random strings can be added in schema.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With