diff options
author | Francois Perrad <francois.perrad@gadz.org> | 2010-10-22 18:48:01 +0200 |
---|---|---|
committer | Francois Perrad <francois.perrad@gadz.org> | 2010-10-22 18:48:01 +0200 |
commit | 0bd771b59bf411ad6253bc7af32f3614029407eb (patch) | |
tree | 34d5f0a73ffd7885ff3f66b0c43c10842b69789e | |
parent | update description to current specification (diff) | |
download | api-description-0bd771b59bf411ad6253bc7af32f3614029407eb.tar.gz |
use Pod::Usage
-rw-r--r-- | utils/validator.pl | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/utils/validator.pl b/utils/validator.pl index 732de05..5972102 100644 --- a/utils/validator.pl +++ b/utils/validator.pl @@ -7,11 +7,16 @@ use JSON; use IO::All; use Data::Rx; use Getopt::Long; +use Pod::Usage; GetOptions( + 'help|?' => \my $help, 'schema=s' => \my $schema, 'description=s' => \my $desc, -); +) or pod2usage(1); + +pod2usage(1) if $help; +pod2usage(1) unless $schema && $desc; my $rx = Data::Rx->new; @@ -19,9 +24,10 @@ my $schema_val = $rx->make_schema( read_from_json($schema) ); my $res = $schema_val->check(read_from_json($desc)); if ($res) { - print "ok - $desc is a valide description\n;" -}else{ - print "nok - $desc is not a valide description\n"; + print "ok - $desc is a valid description\n;"; +} +else{ + print "nok - $desc is not a valid description\n"; } sub read_from_json { @@ -31,3 +37,15 @@ sub read_from_json { my $schema_json = JSON::decode_json($schema); $schema_json; } + +__END__ + +=head1 NAME + +validator - valid JSON against Rx schema + +=head1 SYNOPSIS + +validator.pl --schema spore_validation.rx --description api.json + +=cut |