diff options
author | Jesse Luehrs <doy@tozt.net> | 2012-10-15 16:57:51 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2012-10-15 16:57:51 -0500 |
commit | abcf38defd36cf7e25ac4b4d7e07f01d0bbd3cb1 (patch) | |
tree | 6b0c95a15270c4dbabf2b9ec66e79b2f33afe5ca /lib/MooseX | |
parent | 5bd93bcd1e74bfd234d7751fcc2e9582104ad5a9 (diff) | |
download | moosex-validation-doctypes-abcf38defd36cf7e25ac4b4d7e07f01d0bbd3cb1.tar.gz moosex-validation-doctypes-abcf38defd36cf7e25ac4b4d7e07f01d0bbd3cb1.zip |
missing hashref/arrayref errors still need formatting
also, they weren't being generated at all if the data was missing
altogether
Diffstat (limited to 'lib/MooseX')
-rw-r--r-- | lib/MooseX/Meta/TypeConstraint/Doctype.pm | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/MooseX/Meta/TypeConstraint/Doctype.pm b/lib/MooseX/Meta/TypeConstraint/Doctype.pm index f18da4c..dbc1289 100644 --- a/lib/MooseX/Meta/TypeConstraint/Doctype.pm +++ b/lib/MooseX/Meta/TypeConstraint/Doctype.pm @@ -117,7 +117,7 @@ sub _validate_doctype { match_on_type $doctype => ( 'HashRef' => sub { if (!find_type_constraint('HashRef')->check($data)) { - $errors = $data; + $errors = $self->_format_error($data, $prefix); } else { for my $key (keys %$doctype) { @@ -147,7 +147,7 @@ sub _validate_doctype { }, 'ArrayRef' => sub { if (!find_type_constraint('ArrayRef')->check($data)) { - $errors = $data; + $errors = $self->_format_error($data, $prefix); } else { for my $i (0..$#$doctype) { @@ -178,7 +178,7 @@ sub _validate_doctype { my $tc = Moose::Util::TypeConstraints::find_or_parse_type_constraint($doctype); die "Unknown type $doctype" unless $tc; if (!$tc->check($data)) { - $errors = "invalid value " . dump($data) . " for '$prefix'"; + $errors = $self->_format_error($data, $prefix); } }, => sub { @@ -194,6 +194,13 @@ sub _validate_doctype { ); } +sub _format_error { + my $self = shift; + my ($data, $prefix) = @_; + + return "invalid value " . dump($data) . " for '$prefix'"; +} + no Moose; 1; |