From 7614b7bc2e22d1de5f8f4529bb9962930575a914 Mon Sep 17 00:00:00 2001 From: Tom Bloor Date: Wed, 26 Apr 2017 20:53:27 +0100 Subject: [PATCH] Possible fix for postcode validator not working all the time --- lib/Pear/LocalLoop/Plugin/Validators.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/Pear/LocalLoop/Plugin/Validators.pm b/lib/Pear/LocalLoop/Plugin/Validators.pm index 199d878..ecdefb7 100644 --- a/lib/Pear/LocalLoop/Plugin/Validators.pm +++ b/lib/Pear/LocalLoop/Plugin/Validators.pm @@ -32,8 +32,9 @@ sub register { try { $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 {