.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "JSON::Validator::Error 3pm" .TH JSON::Validator::Error 3pm "2023-03-06" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" JSON::Validator::Error \- JSON::Validator error object .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& use JSON::Validator::Error; \& my $err = JSON::Validator::Error\->new($path, $message); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" JSON::Validator::Error is a class representing validation errors from JSON::Validator. .SH "ATTRIBUTES" .IX Header "ATTRIBUTES" .SS "details" .IX Subsection "details" .Vb 4 \& 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; .Ve .PP Details about the error: .IP "1." 2 Often the category of tests that was run. Example values: allOf, anyOf, array, const, enum, format, integer, not, null, number, object, oneOf and string. .IP "2." 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, .IP "3." 2 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. .SS "message" .IX Subsection "message" .Vb 1 \& my $str = $error\->message; .Ve .PP A human readable description of the error. Defaults to being being constructed from \*(L"details\*(R". See the \f(CW$MESSAGES\fR variable in the source code for more details. .PP As an \s-1EXPERIMENTAL\s0 hack you can localize \f(CW$JSON::Validator::Error::MESSAGES\fR to get i18n support. Example: .PP .Vb 4 \& sub validate_i18n { \& local $JSON::Validator::Error::MESSAGES = { \& allOf => {type => \*(Aq/allOf Forventet %3 \- fikk %4.\*(Aq}, \& }; \& \& my @error_norwegian = $jv\->validate({age => 42}); \& } .Ve .PP Note that the error messages might contain a mix of English and the local language. Run some tests to see how it looks. .SS "path" .IX Subsection "path" .Vb 1 \& my $str = $error\->path; .Ve .PP A \s-1JSON\s0 pointer to where the error occurred. Defaults to \*(L"/\*(R". .SH "METHODS" .IX Header "METHODS" .SS "new" .IX Subsection "new" .Vb 3 \& my $error = JSON::Validator::Error\->new(\e%attributes); \& my $error = JSON::Validator::Error\->new($path, \e@details); \& my $error = JSON::Validator::Error\->new($path, \e@details); .Ve .PP Object constructor. .SS "to_string" .IX Subsection "to_string" .Vb 1 \& my $str = $error\->to_string; .Ve .PP Returns the \*(L"path\*(R" and \*(L"message\*(R" part as a string: \*(L"$path: \f(CW$message\fR\*(R". .SH "OPERATORS" .IX Header "OPERATORS" JSON::Validator::Error overloads the following operators: .SS "bool" .IX Subsection "bool" .Vb 1 \& my $bool = !!$error; .Ve .PP Always true. .SS "stringify" .IX Subsection "stringify" .Vb 1 \& my $str = "$error"; .Ve .PP Alias for \*(L"to_string\*(R". .SH "SEE ALSO" .IX Header "SEE ALSO" JSON::Validator.