JSON::TinyValidatorV4 - JSON Validator for v4 JSON Schema
use JSON::TinyValidatorV4; use Data::Dumper; my $schema = { type => 'object', properties => { latitude => { type => 'number' }, longitude => { type => 'number' } } }; my $data = { longitude => -128.323746, latitude => -24.375870, elevation=> 23.1 }; my $tv4 = JSON::TinyValidatorV4->new; print $tv4->validate( $data, $schema ), "\n"; # prints "1" print $tv4->validate( $data, $schema, 0, 1 ), "\n"; # prints "0" print Dumper( $tv4->validateResult( $data, $schema, 0, 1 ) ); # prints: # $VAR1 = { # 'valid' => 0, # 'error' => { # 'message' => 'Unknown property (not in schema)', # 'dataPath' => '/elevation', # ... # }, # 'missing' => [] # };
This package is a wrapper for Tiny Validator. It uses json-schema draft v4 to validate simple values and complex objects. For details see also SEE ALSO.
validates $data with $schema. $checkRecursive and $banUnknownProperties are false by default. returns 0 or 1.
validates $data with $schema. $checkRecursive and $banUnknownProperties are false by default. returns an result hash:
{ valid => 0, error => {...}, missing => [...] }
Tiny Validator at github: L<https://github.com/geraintluff/tv4>
Michael Langner, mila at cpan dot org
This package uses an embedded copy of Tiny Validator (https://github.com/geraintluff/tv4) to do all the validation work.
Copyright 2015 Michael Langner, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install JSON::TinyValidatorV4, copy and paste the appropriate command in to your terminal.
cpanm
cpanm JSON::TinyValidatorV4
CPAN shell
perl -MCPAN -e shell install JSON::TinyValidatorV4
For more information on module installation, please visit the detailed CPAN module installation guide.