NAME

JSON::Schema::Draft201909::Result - Contains the result of a JSON Schema evaluation

VERSION

version 0.009

SYNOPSIS

use JSON::Schema::Draft201909;
my $js = JSON::Schema::Draft201909->new;
my $result = $js->evaluate($data, $schema);
my @errors = $result->errors;

my $result_data_encoded = encode_json($result); # calls TO_JSON

# use in numeric and boolean context
say sprintf('got %d %ss', $result, ($result ? 'annotation' : 'error'));

# use in string context
say 'full results: ', $result;

DESCRIPTION

This object holds the complete results of evaluating a data payload against a JSON Schema using JSON::Schema::Draft201909.

OVERLOADS

The object contains a boolean overload, which evaluates to the value of "result", so you can use the result of "evaluate" in JSON::Schema::Draft201909 in boolean context.

ATTRIBUTES

result

A boolean. Indicates whether validation was successful or failed.

errors

Returns an array of JSON::Schema::Draft201909::Error objects.

output_format

One of: flag, basic, detailed, verbose. Defaults to basic.

METHODS

format

Returns a data structure suitable for serialization; requires one argument specifying the output format to use, which corresponds to the formats documented in https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.10.4. The only supported formats at this time are flag and basic.

TO_JSON

Calls "format" with the style configured in "output_format".

count

Returns the number of errors, when the result is false, or zero otherwise.

SUPPORT

Bugs may be submitted through https://github.com/karenetheridge/JSON-Schema-Draft201909/issues.

I am also usually active on irc, as 'ether' at irc.perl.org and irc.freenode.org.

AUTHOR

Karen Etheridge <ether@cpan.org>

COPYRIGHT AND LICENCE

This software is copyright (c) 2020 by Karen Etheridge.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.