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:
Jonathan Druart 2023-07-21 10:46:41 +02:00 committed by Tomas Cohen Arazi
parent b987fd5afd
commit 3d2267b643
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
2 changed files with 5 additions and 2 deletions

View File

@ -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" } )

View File

@ -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;
};