Add postcode validation for Slovenia (#25174)
Add postcode validation for Slovenia
This commit is contained in:
parent
5c85f3c63d
commit
d20d429e32
|
@ -96,7 +96,9 @@ class WC_Validation {
|
|||
case 'NL':
|
||||
$valid = (bool) preg_match( '/^([1-9][0-9]{3})(\s?)(?!SA|SD|SS)[A-Z]{2}$/i', $postcode );
|
||||
break;
|
||||
|
||||
case 'SI':
|
||||
$valid = (bool) preg_match( '/^([1-9][0-9]{3})$/', $postcode );
|
||||
break;
|
||||
default:
|
||||
$valid = true;
|
||||
break;
|
||||
|
|
|
@ -107,7 +107,15 @@ class WC_Tests_Validation extends WC_Unit_Test_Case {
|
|||
array( false, WC_Validation::is_postcode( '3852 sa', 'NL' ) ),
|
||||
);
|
||||
|
||||
return array_merge( $it, $gb, $us, $ch, $br, $ca, $nl );
|
||||
$si = array(
|
||||
array( true, WC_Validation::is_postcode( '1234', 'SI' ) ),
|
||||
array( true, WC_Validation::is_postcode( '1000', 'SI' ) ),
|
||||
array( true, WC_Validation::is_postcode( '9876', 'SI' ) ),
|
||||
array( false, WC_Validation::is_postcode( '12345', 'SI' ) ),
|
||||
array( false, WC_Validation::is_postcode( '0123', 'SI' ) ),
|
||||
);
|
||||
|
||||
return array_merge( $it, $gb, $us, $ch, $br, $ca, $nl, $si );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue