summaryrefslogtreecommitdiffstats
path: root/t/stringify.t
blob: c8db5a44f2803c3c8ed61dbd32933637e1e0f75e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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;