|
NAMEJSON::Validator::Error - JSON::Validator error objectSYNOPSISuse JSON::Validator::Error; my $err = JSON::Validator::Error->new($path, $message); DESCRIPTIONJSON::Validator::Error is a class representing validation errors from JSON::Validator.ATTRIBUTESdetailsmy $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:
messagemy $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. pathmy $str = $error->path; A JSON pointer to where the error occurred. Defaults to "/". METHODSnewmy $error = JSON::Validator::Error->new(\%attributes); my $error = JSON::Validator::Error->new($path, \@details); my $error = JSON::Validator::Error->new($path, \@details); Object constructor. to_stringmy $str = $error->to_string; Returns the "path" and "message" part as a string: "$path: $message". OPERATORSJSON::Validator::Error overloads the following operators:boolmy $bool = !!$error; Always true. stringifymy $str = "$error"; Alias for "to_string". SEE ALSOJSON::Validator.
Visit the GSP FreeBSD Man Page Interface. |