NAME
Swagger2::SchemaValidator - Validate JSON schemas
DESCRIPTION
Swagger2::SchemaValidator is a class for validating JSON schemas.
The validation process is supposed to be compatible with draft 4 of the JSON schema specification. Please submit a bug report if it is not.
SYNOPSIS
use Swagger2::SchemaValidator;
my $validator = Swagger2::SchemaValidator->new;
@errors = $validator->validate($data, $schema);
Example:
warn $validator->validate(
{
nick => "batman",
},
{
type => "object",
properties => {
nick => {type => "string", minLength => 3, maxLength => 10, pattern => qr{^\w+$} }
},
},
);
SEE ALSO
METHODS
validate
@errors = $self->validate($data, $schema);
Validates $data
against a given JSON $schema
. @errors
will contain objects with containing the validation errors. It will be empty on success.
Example error element:
bless {
message => "Some description",
path => "/json/path/to/node",
}, "Swagger2::SchemaValidator::Error"
The error objects are always true in boolean context and will stringify. The stringification format is subject to change.
COPYRIGHT AND LICENSE
Copyright (C) 2014, Jan Henning Thorsen
This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.
AUTHOR
Jan Henning Thorsen - jhthorsen@cpan.org