Thanks for posting Stevan's gist... I hadn't seen that elsewhere.
When I first saw Ovid's post I could see a MooseX::Declare lightbulb going off in my head ;-)
use 5.010;
use MooseX::Declare;
class Foo {
use MooseX::Types -declare => [ qw(Filename) ];
use MooseX::Types::Moose qw(Str);
BEGIN {
subtype Filename, as Str, where { -x $_ };
}
method file ( Filename $name ) {
say "Houston, we have a filename: $name";
}
}
my $foo = Foo->new;
my $perl = `which perl`; chomp $perl;
$foo->file( $perl );
$foo->file( 'no_such_file' );
Above throws the expected exeception on 'no_such_file'.