Possible fix for postcode validator not working all the time

This commit is contained in:
Tom Bloor 2017-04-26 20:53:27 +01:00
parent ae6884202a
commit 7614b7bc2e

View file

@ -32,8 +32,9 @@ sub register {
try { try {
$postcode = Geo::UK::Postcode->new( $value ); $postcode = Geo::UK::Postcode->new( $value );
}; };
return defined( $postcode ) && ( $postcode->valid ) && ! ( $postcode->partial ) ? undef : 1; return 1 unless defined( $postcode );
return 1 if $postcode->partial;
return undef if $postcode->valid;
}); });
$app->validator->add_check( number => sub { $app->validator->add_check( number => sub {