more verbose errors in IsValid plugins
parent
cc598fe550
commit
ee60cd0175
|
@ -19,10 +19,16 @@ handle remainder => sub {
|
|||
from_json($_);
|
||||
return 'valid';
|
||||
} catch {
|
||||
return 'invalid';
|
||||
$_ =~ /^(.* at character offset \d+ .*) at/;
|
||||
|
||||
if ($1) {
|
||||
return "invalid: $1"
|
||||
} else {
|
||||
return "invalid"
|
||||
}
|
||||
};
|
||||
|
||||
return "Your JSON is $result!";
|
||||
return "Your JSON is $result!"
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
|
@ -19,7 +19,13 @@ handle remainder => sub {
|
|||
XMLin($_);
|
||||
return 'valid';
|
||||
} catch {
|
||||
return 'invalid';
|
||||
$_ =~ /^\n(.* at line \d+, column \d+, byte \d+) at/;
|
||||
|
||||
if ($1) {
|
||||
return "invalid: $1"
|
||||
} else {
|
||||
return "invalid"
|
||||
}
|
||||
};
|
||||
|
||||
return "Your XML is $result!";
|
||||
|
|
|
@ -16,7 +16,7 @@ ddg_goodie_test(
|
|||
|
||||
ddg_goodie_test(
|
||||
[qw(DDG::Goodie::IsValid::JSON)],
|
||||
'is valid json {"test" "lol"}' => test_zci('Your JSON is invalid!'),
|
||||
'is valid json {"test" "lol"}' => test_zci('Your JSON is invalid: \':\' expected, at character offset 8 (before ""lol"}")!'),
|
||||
);
|
||||
|
||||
ddg_goodie_test(
|
||||
|
@ -26,7 +26,7 @@ ddg_goodie_test(
|
|||
|
||||
ddg_goodie_test(
|
||||
[qw(DDG::Goodie::IsValid::XML)],
|
||||
'is valid xml <test>lol' => test_zci('Your XML is invalid!'),
|
||||
'is valid xml <test>lol' => test_zci('Your XML is invalid: no element found at line 1, column 9, byte 9!'),
|
||||
);
|
||||
|
||||
done_testing;
|
||||
|
|
Loading…
Reference in New Issue