You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can also use it as a PHP8 Attribute, with parameters passed as an array of options, for example:
52
+
You can also use it as a PHP8 Attribute with named parameters:
55
53
```php
56
54
<?php
57
55
58
56
use ZipCodeValidator\Constraints\ZipCode;
59
57
60
58
class Address
61
59
{
62
-
#[ZipCode(['iso'=>'DE'])
60
+
#[ZipCode(iso: 'DE')]
63
61
protected $zipCode;
64
62
}
65
63
```
66
64
65
+
Legacy array options are still supported for backward compatibility:
66
+
```php
67
+
#[ZipCode(['iso' => 'DE'])]
68
+
```
69
+
67
70
> Please consider to inject a valid ISO 3166 2-letter country code (e.g. DE, US, FR)!
68
71
69
72
> NOTE: This library validates against known zip code regex patterns and does not validate the existence of a zipcode.
@@ -117,10 +120,7 @@ protected $zipCode;
117
120
### Case insensitive zip code matching
118
121
In case you want to match the zip code in a case insensitive way you have to pass a `caseSensitiveCheck` parameter with `false` value via the constructor:
119
122
```php
120
-
$constraint = new ZipCode([
121
-
'iso' => 'GB',
122
-
'caseSensitiveCheck' => false
123
-
]);
123
+
$constraint = new ZipCode(iso: 'GB', caseSensitiveCheck: false);
124
124
125
125
```
126
126
By the default the library is using case sensitive zip code matching.
0 commit comments