From c5ee7923bb6d38f138e58e7da5f9dfaa85bb9721 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 11 Oct 2012 13:49:04 -0500 Subject: allow serializing the error objects as json --- lib/MooseX/Validation/Doctypes/Errors.pm | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib') diff --git a/lib/MooseX/Validation/Doctypes/Errors.pm b/lib/MooseX/Validation/Doctypes/Errors.pm index 023493c..ca4d54d 100644 --- a/lib/MooseX/Validation/Doctypes/Errors.pm +++ b/lib/MooseX/Validation/Doctypes/Errors.pm @@ -104,6 +104,15 @@ has extra_data => ( predicate => 'has_extra_data', ); +sub TO_JSON { + my $self = shift; + + return { + ($self->has_errors ? (errors => $self->errors) : ()), + ($self->has_extra_data ? (extra_data => $self->extra_data) : ()), + }; +} + __PACKAGE__->meta->make_immutable; no Moose; -- cgit v1.2.3