Merge pull request #23837 from woocommerce/fix/23834
Make NL postcode validation more flexible
This commit is contained in:
commit
606c0417a9
|
@ -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:
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue