3 use MooseX::Types -declare [qw/ ValidAppName ValidAppComponent /];
5 my $appname_re = qr/[\w:]+/;
6 my $regex = qr/$appname_re::(M|V|C|Model|View|Controller)::.*/;
10 where { /^$appname_re$/ && ! /$regex/ };
12 subtype ValidAppComponent,
17 from ValidAppComponent,
18 via { Catalyst::Utils::class2appclass($_); };
21 use Test::More 'no_plan';
22 use Moose::Util::TypeContraints;
23 use My::Types qw/ValidAppName ValidAppComponent/;
25 my $app_tc = find_type_constraint(ValidAppName);
27 ok !$app_tc->check('');
28 ok $app_tc->check('MyApp');
30 my $comp_tc = find_type_constraint(ValidAppComponent);
32 ok !$comp_tc->check('');
33 ok !$comp_tc->check('MyApp');
34 ok $comp_tc->check('MyApp::Model::Foo');
36 is $app_tc->coerce('MyApp::Model::Foo'), 'MyApp';