From cd59caeec925cf0bf8625d567a442e3c46ae7475 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 11 Oct 2012 14:22:55 -0500 Subject: also provide stringification for the error object --- t/stringify.t | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 t/stringify.t (limited to 't/stringify.t') diff --git a/t/stringify.t b/t/stringify.t new file mode 100644 index 0000000..c8db5a4 --- /dev/null +++ b/t/stringify.t @@ -0,0 +1,33 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; + +use Moose::Util::TypeConstraints 'find_type_constraint'; + +use MooseX::Validation::Doctypes; + +doctype 'Person' => { + id => 'Str', + name => 'Str', + title => 'Str', +}; + +{ + my $person = find_type_constraint('Person'); + my $errors = $person->validate({ foo => "bar" }); + + is( + "$errors", + "invalid value undef for 'id'\n" + . "invalid value undef for 'name'\n" + . "invalid value undef for 'title'\n" + . "extra data found:\n" + . "{\n" + . " 'foo' => 'bar'\n" + . "}", + "stringified properly" + ); +} + +done_testing; -- cgit v1.2.3