Why not adopt me?
This distribution is up for adoption!
If you're interested then please contact the PAUSE module admins via
email.
NAME
JSON::TinyValidatorV4 - JSON Validator for v4 JSON Schema
SYNOPSIS
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;
$tv4
->validate(
$data
,
$schema
),
"\n"
;
# prints "1"
$tv4
->validate(
$data
,
$schema
, 0, 1 ),
"\n"
;
# prints "0"
Dumper(
$tv4
->validateResult(
$data
,
$schema
, 0, 1 ) );
# prints:
# $VAR1 = {
# 'valid' => 0,
# 'error' => {
# 'message' => 'Unknown property (not in schema)',
# 'dataPath' => '/elevation',
# ...
# },
# 'missing' => []
# };
DESCRIPTION
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.
validate( $data, $schema, [ $checkRecursive=0, $banUnknownProperties=0 ] )
validates $data with $schema. $checkRecursive and $banUnknownProperties are false by default. returns 0 or 1.
validateResult( $data, $schema, [ $checkRecursive=0, $banUnknownProperties=0 ] )
validates $data with $schema. $checkRecursive and $banUnknownProperties are false by default. returns an result hash:
{
valid
=> 0,
error
=> {...},
missing
=> [...]
}
SEE ALSO
Tiny Validator at github: L<https://github.com/geraintluff/tv4>
AUTHORS
Michael Langner, mila at cpan dot org
THANKS
This package uses an embedded copy of Tiny Validator (https://github.com/geraintluff/tv4) to do all the validation work.
COPYRIGHT & LICENSE
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.