Skip to content

Instantly share code, notes, and snippets.

@jeremy-donson
Last active December 6, 2017 05:50
Show Gist options
  • Save jeremy-donson/204b27e59f111f63b95830df7797789b to your computer and use it in GitHub Desktop.
Save jeremy-donson/204b27e59f111f63b95830df7797789b to your computer and use it in GitHub Desktop.
Trying to use py3 or shyaml to validate a yml file.
# Generate yaml file.
echo -e "# http://yaml.org/spec/\n---\nYAML SPEC RELEASES: DATE\n - Release 1.0: 2004-01-29\n\
- Release 1.1: 2004-12-30 \n - Release 1.2: 2009-09-29\n—--" > yaml-spec-releases-and-dates.yml
cat yaml-spec-releases-and-dates.yml | shyaml -y
cat > known-good-yaml.yml <<EOF
---
invoice: 34843
date : 2001-01-23
bill-to: &id001
given : Chris
family : Dumars
address:
lines: |
458 Walkman Dr.
Suite #292
city : Royal Oak
state : MI
postal : 48046
ship-to: *id001
product:
- sku : BL394D
quantity : 4
description : Basketball
price : 450.00
- sku : BL4438H
quantity : 1
description : Super Hoop
price : 2392.00
tax : 251.42
total: 4443.52
comments: >
Late afternoon is best.
Backup contact is Nancy
Billsmer @ 338-4338.
EOF
cat known-good-yaml.yml | shyaml -y
# Alt method: https://liquidat.wordpress.com/2016/01/21/short-tip-verify-yaml-in-shell-via-python-one-liner/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment