NAME

JSON::Schema::Validate::Error - JSON Schema Exception

SYNOPSIS

use JSON::Schema::Validate::Error;
my $ex = JSON::Schema::Validate::Error->new( $json_pointer, $error_message ) || 
    die( JSON::Schema::Validate::Error->error );

VERSION

v0.1.0

DESCRIPTION

This class represents JSON::Schema::Validate errors that are found upon validating the schema provided.

The objects of this class are overloadable, which means they stringify if called in a string context.

They can also be compared, such as:

say $ex1 eq $ex2;

This will not check the two objects are the same, but rather tha their path and their message are identical.

CONSTRUCTOR

my $ex = JSON::Schema::Validate::Error->new( $json_pointer, $error_message )

Instantiate a new JSON::Schema::Validate::Error object, and returns it.

It takes the following parameters:

  • $json_pointer

    A JSON pointer representing the path in the JSON data where the error occurred.

  • $error_message

    An error text message that describes the error.

METHODS

as_string

say $ex; # some/path/field: some error message

Returns the string representation of the error.

message

$ex->message( "Some error" );
$ex->message; # Some error

Sets or gets the object error message.

path

$ex->path( $json_pointer );
$ex->path; # /some/where/field

Sets or gets the object error path (JSON pointer).

THREAD SAFETY

This module is thread-safe.

It does not use nor manipulate global variables, and each instance of JSON::Schema::Validate::Error is self-contained and does not share any mutable state across threads.

AUTHOR

Jacques Deguest <jack@deguest.jp>

SEE ALSO

JSON::Schema::Validate

COPYRIGHT & LICENSE

Copyright(c) 2025 DEGUEST Pte. Ltd.

All rights reserved.

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