|
sub run_tests {
my %allowed = ( foo => 1, baz => 1 );
eval {
my @a = ( foo => 'foo' );
validate(
@a , {
foo => {
callbacks => {
is_allowed => sub { $allowed { lc $_ [0] } }
},
}
}
);
};
is( $@, q{} );
eval {
my @a = ( foo => 'aksjgakl' );
validate(
@a , {
foo => {
callbacks => {
is_allowed => sub { $allowed { lc $_ [0] } }
},
}
}
);
};
if ( $ENV {PERL_NO_VALIDATION} ) {
is( $@, q{} );
}
else {
like( $@, qr/is_allowed/ );
}
eval { Foo->new( storage => 'InMemory' , file => 'something' ); };
is( $@, q{} );
done_testing();
}
my %storage = map { lc $_ => $_ } ( qw( InMemory XML BerkeleyDB ) );
sub new {
my $class = shift ;
local $^W = 1;
my %p = validate_with(
params => \ @_ ,
spec => {
storage => {
callbacks => {
'is a valid storage type' => sub { $storage { lc $_ [0] } }
},
},
},
allow_extra => 1,
);
return 1;
}
1;
|