summaryrefslogtreecommitdiff
path: root/utils/validator.pl
blob: 732de05843d52ed4077f431f86b89aa6c737cf49 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env perl

use strict;
use warnings;

use JSON;
use IO::All;
use Data::Rx;
use Getopt::Long;

GetOptions(
    'schema=s'      => \my $schema,
    'description=s' => \my $desc,
);

my $rx = Data::Rx->new;

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";
}

sub read_from_json {
    my ($file) = @_;

    my $schema < io $file;
    my $schema_json = JSON::decode_json($schema);
    $schema_json;
}