yaml file validation is one of the important to check for correctness of an content and syntax rules for yaml file format

Validation checks for

  • Syntax rules for content
  • format yaml content
  • Check errors for node has valid key, not found , valid child nodes
  • Auto completion
  • auto indentation

Usually There are lot of linter programs available to check for validation of yaml file. There are number of ways to check yaml file validation

Command line to check yaml file validation

yamllint is one of the program to check via command line

First, Install yamllint

sudo apt-get install yamllint // ubuntu
sudo dnf install yamllint // linux

you can validate yaml file using

yamllint input.yaml

In python, pyyaml package provides yaml validation with yamllint

Here is an command to install package

pip install --user yamllint

using python command, we can validate and print the validation logs to console

python -c 'import yaml, sys; print(yaml.safe_load(sys.stdin))' < input.yaml

YAML validation with IDE

IDE are popular code editor to write and validate the code

There are popular code IDE available

  • Visual studio : Opensource popular editor for popular languages, There are lot of plugins for yaml linter extensions, You can use redhat yaml
  • Eclipse : popular editor for java and python , yaml-editor can be used for yaml validation
  • Intelli IDE: yaml plugin provides yaml language support in intelli editor

Yaml validation online tools

There are various multiple online tools, One of them yaml validation online