expanded IsValid trigger

master
Dylan Lloyd 2012-08-06 13:36:46 -04:00
parent e8a40171be
commit 997e365633
2 changed files with 4 additions and 5 deletions

View File

@ -15,14 +15,13 @@ zci is_cached => 1;
triggers any => 'json'; triggers any => 'json';
handle remainder => sub { handle remainder => sub {
return unless $_ =~ /valid\s*(.*)$/; return unless s/ ?(is )?valid\?? ?//gi;
my ($result, $error) = try { my ($result, $error) = try {
from_json($1); from_json $_;
return 'valid!'; return 'valid!';
} catch { } catch {
$_ =~ /^(.* at character offset \d+ .*) at/; $_ =~ /^(.* at character offset \d+ .*) at/;
return ('invalid: ', $1); return ('invalid: ', $1);
}; };

View File

@ -15,10 +15,10 @@ zci is_cached => 1;
triggers any => 'xml'; triggers any => 'xml';
handle remainder => sub { handle remainder => sub {
return unless $_ =~ /valid\s*(.*)$/; return unless s/ ?(is )?valid\?? ?//gi;
my ($result, $error) = try { my ($result, $error) = try {
XMLin($1); XMLin $_;
return 'valid!'; return 'valid!';
} catch { } catch {
$_ =~ /^\n(.* at line \d+, column \d+, byte \d+) at/; $_ =~ /^\n(.* at line \d+, column \d+, byte \d+) at/;