GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
JSON::Validator::Error(3) User Contributed Perl Documentation JSON::Validator::Error(3)

JSON::Validator::Error - JSON::Validator error object

  use JSON::Validator::Error;
  my $err = JSON::Validator::Error->new($path, $message);

JSON::Validator::Error is a class representing validation errors from JSON::Validator.

  my $error     = $error->details(["generic", "generic"]);
  my $error     = $error->details([qw(array type object)]);
  my $error     = $error->details([qw(format date-time Invalid)]);
  my $array_ref = $error->details;

Details about the error:

1.
Often the category of tests that was run. Example values: allOf, anyOf, array, const, enum, format, integer, not, null, number, object, oneOf and string.
2.
Often the test that failed. Example values: additionalItems, additionalProperties, const, enum, maxItems, maxLength, maxProperties, maximum, minItems, minLength. minProperties, minimum, multipleOf, not, null, pattern, required, type and uniqueItems,
3.
The rest of the list contains parameters for the test that failed. It can be a plain human-readable string or numbers indicating things such as max/min values.

  my $str = $error->message;

A human readable description of the error. Defaults to being being constructed from "details". See the $MESSAGES variable in the source code for more details.

As an EXPERIMENTAL hack you can localize $JSON::Validator::Error::MESSAGES to get i18n support. Example:

  sub validate_i18n {
    local $JSON::Validator::Error::MESSAGES = {
      allOf => {type => '/allOf Forventet %3 - fikk %4.'},
    };

    my @error_norwegian = $jv->validate({age => 42});
  }

Note that the error messages might contain a mix of English and the local language. Run some tests to see how it looks.

  my $str = $error->path;

A JSON pointer to where the error occurred. Defaults to "/".

  my $error = JSON::Validator::Error->new(\%attributes);
  my $error = JSON::Validator::Error->new($path, \@details);
  my $error = JSON::Validator::Error->new($path, \@details);

Object constructor.

  my $str = $error->to_string;

Returns the "path" and "message" part as a string: "$path: $message".

JSON::Validator::Error overloads the following operators:

  my $bool = !!$error;

Always true.

  my $str = "$error";

Alias for "to_string".

JSON::Validator.
2021-10-02 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.