Data-Validation

 view release on metacpan or  search on metacpan

t/10base.t  view on Meta::CPAN

}

my $f = {};

is test_val( $f, undef, 1 ), "Field '[?]' validation configuration not found",
   'No field def 1';
is test_val( $f, 'test', 1), "Field 'test' validation configuration not found",
   'No field def 2';

$f->{fields}->{test}->{validate} = q(isHexadecimal);
is test_val( $f, q(test), q(alive) ), q(Hexadecimal), 'Not hexadecimal';
is test_val( $f, q(test), q(dead) ),  q(dead),         'Is hexadecimal';

my ($value, $e) = new_e( $f, q(test), q(alive) );

like $e->explain, qr{ \Qcan only contain\E }imx, 'Explains error';

$f->{fields}->{test}->{validate} = q(isMandatory);
is test_val( $f, q(test), undef ), q(Mandatory), 'Missing field';
is test_val( $f, q(test), 1 ),     q(1),       'Mandatory field';

($value, $e) = new_e( $f, q(test), undef );
is $e->explain, q(), 'Default explain';



( run in 0.678 second using v1.01-cache-2.11-cpan-39bf76dae61 )