Merge pull request #23837 from woocommerce/fix/23834

Make NL postcode validation more flexible
This commit is contained in:
Claudio Sanches 2019-06-24 12:17:53 -03:00 committed by GitHub
commit 606c0417a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -94,7 +94,7 @@ class WC_Validation {
$valid = (bool) preg_match( '/^([0-9]{3})(\s?)([0-9]{2})$/', $postcode );
break;
case 'NL':
$valid = (bool) preg_match( '/^[1-9][0-9]{3}\s(?!SA|SD|SS)[A-Z]{2}$/', $postcode );
$valid = (bool) preg_match( '/^([1-9][0-9]{3})(\s?)(?!SA|SD|SS)[A-Z]{2}$/i', $postcode );
break;
default:

View File

@ -98,7 +98,16 @@ class WC_Tests_Validation extends WC_Unit_Test_Case {
array( false, WC_Validation::is_postcode( '0A0A0A', 'CA' ) ),
);
return array_merge( $it, $gb, $us, $ch, $br, $ca );
$nl = array(
array( true, WC_Validation::is_postcode( '3852GC', 'NL' ) ),
array( true, WC_Validation::is_postcode( '3852 GC', 'NL' ) ),
array( true, WC_Validation::is_postcode( '3852 gc', 'NL' ) ),
array( false, WC_Validation::is_postcode( '3852SA', 'NL' ) ),
array( false, WC_Validation::is_postcode( '3852 SA', 'NL' ) ),
array( false, WC_Validation::is_postcode( '3852 sa', 'NL' ) ),
);
return array_merge( $it, $gb, $us, $ch, $br, $ca, $nl );
}
/**