VSO
view release on metacpan or search on metacpan
confess "Subtype '$name' already exists"
if $VSO::Subtype::types{$name};
_add_subtype(
name => $name,
as => $args{as},
where => $args{where} || sub { 1 },
message => $args{message} || sub { "Must be a valid '$name'" },
);
}# end subtype()
sub as { as => shift, @_ }
sub where(&) { where => $_[0] }
sub message(&) { message => $_[0] }
sub coerce($;@)
{
my ($to, %args) = @_;
my ($pkg,$filename,$line) = caller;
confess "Coercion from '$args{from}' to '$to' is already defined in $filename line $line"
if defined($_coercions->{$to}->{$args{from}});
$_coercions->{$to}->{$args{from}} = $args{via};
}# end coerce()
sub from { from => shift, @_ }
sub via(&) { via => $_[0] }
sub enum($$)
{
my ($name, $vals) = @_;
_add_subtype(
name => $name,
as => 'Str',
where => sub {
my $val = $_;
( run in 0.738 second using v1.01-cache-2.11-cpan-49f99fa48dc )