In the short term, there's probably a fairly reasonable one liner you can use.
perl -MYAML -e "eval { YAML::LoadFile($ARGV[0]); }; exit($@ ? 1 : 0)
}" file.yaml
Or something similar.
In the longer term, it's more complicated, because YAML isn't
compliant with YAML the specification.
Since the "authorative" parser is libyaml, which is what YAML::XS uses
(I believe), crafting a script around that might be a better option.
Adam K
2010/1/20 Evan Carroll via RT <bug-YAML@rt.cpan.org>:
Show quoted text> Tue Jan 19 15:38:20 2010: Request 53828 was acted upon.
> Transaction: Ticket created by ECARROLL
> Queue: YAML
> Subject: wishlist: /bin/yaml-check-valid
> Broken in: (no value)
> Severity: Wishlist
> Owner: Nobody
> Requestors: perl@evancarroll.com
> Status: new
> Ticket <URL:
https://rt.cpan.org/Ticket/Display.html?id=53828 >
>
>
> I'm having a bitch of a time keeping my yaml files valid, it would be
> nice if there was a program packaged with the distribution like
> `xmlstarlet` to xml, that gives me something I can call in a git-pre-
> commit hook, and dies if the yaml isn't valid.
> --
> Evan Carroll
> System Lord of the Internets
>
http://www.evancarroll.com
>