YAML Syntax Validator Script

I've been tasked with creating and editing quite a few YAML files, but rather than using an online syntax validator, I'm looking to run it through a script. Are there any available scripts that will test YAML Syntax? I found one through Perl that used perl::xs, but it wasn't particularly portable.

Answers


You should try YAML on CPAN, which is pure perl without dependencies, so it's portable. You can even just download it and put them with your validator script without installation.

Here is a example validator script:

use YAML qw(LoadFile);
use Data::Dumper;

my $data = LoadFile($ARGV[0]);
print Dumper($data);

If any error occurred, the error message will tell you where's the problem:

YAML Error: Expected separator '---'
   Code: YAML_PARSE_ERR_NO_SEPARATOR
   Line: 1
   Document: 2
 at /Users/alec/perl5/perlbrew/perls/p5161t/lib/site_perl/5.16.1/YAML/Loader.pm line 81.

Need Your Help

heavy iTunes Connect scraping

screen-scraping itunes itunesconnect

I'm looking at different options to get the sales reports and other data out of the iTunes Connect website. Since Apple doesn't provide an API, all the solutions I found are based on scraping the p...

HIVE script - Specify file name as S3 Location

amazon-s3 hive

I am exporting data from DynamoDB to S3 using follwing script: