{
require File::Temp;
require JSON::MaybeXS;
#require String::ShellQuote;
my $data = shift;
state $json = JSON::MaybeXS->new->allow_nonref;
# code t
s
my $src = "var validator = $v_src;\n\n".
"console.log(JSON.stringify(validator(".
$json->encode($data).")))";
my ($jsh, $jsfn) = File::Temp::tempfile();
file $jsfn: $!";
my $out = IPC::System::Options::readpipe($nodejs_path, $jsfn);
$json->decode($out);
};
}
1;
# ABSTRACT: Some functions to use JavaScript Sah validator code from
my $dt = $cd->{data_term};
$cd->{_ccl_check_type} = "$dt instanceof Array";
}
my $STR = "JSON.stringify";
sub superclause_comparable {
my ($self, $which, $cd) = @_;
my $c = $self->c
= qw(run_spectest_for_js);
sub _encode_json {
state $json = do {
require JSON::MaybeXS;
JSON::MaybeXS->new->allow_nonref;
};
$json->encode(@_);
}
sub run_spectest_for_js
h = Data::Sah->new;
my $js = $sah->get_compiler('js');
my %names; # key: json(schema)
my %counters; # key: type name
my @js_code;
# contr
tname: $reason";
next TEST;
}
my $k = _encode_json($test->{schema});
my $ns = $sah->normalize_schema($test->{schema});
..
$cd->{_ccl_check_type} = "typeof($dt)=='object' && !($dt instanceof Array)";
}
my $STR = "JSON.stringify";
sub superclause_comparable {
my ($self, $which, $cd) = @_;
my $c = $self->c
my ($self, $val) = @_;
state $json = do {
require JSON::MaybeXS;
JSON::MaybeXS->new->allow_nonref;
};
# we need cleaning since json can't handle qr//, for one.
stat
e $cleanser = do {
require Data::Clean::JSON;
Data::Clean::JSON->get_cleanser;
};
$json->encode($cleanser->clone_and_clean($val));
}
sub compile {
my ($self, %args) = @_;