Bug 33940: Consider NULL as valid
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
b987fd5afd
commit
3d2267b643
|
|
@ -51,7 +51,7 @@ Returns whether a cardnumber is valid of not for a given I<Koha::Patron> object.
|
|||
sub is_valid {
|
||||
my ( $class, $cardnumber, $patron ) = @_;
|
||||
|
||||
return Koha::Result::Boolean->new(0)->add_message( { message => "is_empty" } )
|
||||
return Koha::Result::Boolean->new(1)
|
||||
unless defined $cardnumber;
|
||||
|
||||
return Koha::Result::Boolean->new(0)->add_message( { message => "already_exists" } )
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ my $builder = t::lib::TestBuilder->new;
|
|||
|
||||
subtest 'is_valid' => sub {
|
||||
|
||||
plan tests => 21;
|
||||
plan tests => 23;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
|
|
@ -92,6 +92,9 @@ subtest 'is_valid' => sub {
|
|||
ok( !$policy->is_valid(q{1234567890123456}), "1234567890123456 is longer than $pref" );
|
||||
ok( !$policy->is_valid(q{1234567890}), "1234567890 is longer than $pref" );
|
||||
|
||||
ok( $policy->is_valid(undef), "If cardnumber is null, we assume they're allowed" );
|
||||
ok( !$policy->is_valid(""), "Empty string is not correct" );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue