diff options
author | Jesse Luehrs <doy@tozt.net> | 2012-10-11 13:49:04 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2012-10-11 13:49:04 -0500 |
commit | c5ee7923bb6d38f138e58e7da5f9dfaa85bb9721 (patch) | |
tree | 642e92b853ebe9bac3888365e1159ddd2de88652 /lib/MooseX/Validation/Doctypes/Errors.pm | |
parent | 04ba3d16bb9db715e009c09f0af807d8d5848263 (diff) | |
download | moosex-validation-doctypes-c5ee7923bb6d38f138e58e7da5f9dfaa85bb9721.tar.gz moosex-validation-doctypes-c5ee7923bb6d38f138e58e7da5f9dfaa85bb9721.zip |
allow serializing the error objects as json
Diffstat (limited to 'lib/MooseX/Validation/Doctypes/Errors.pm')
-rw-r--r-- | lib/MooseX/Validation/Doctypes/Errors.pm | 9 |
1 files changed, 9 insertions, 0 deletions
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; |