Skip to content

Commit 7c8926d

Browse files
committed
Cast values to string
1 parent 05c89cf commit 7c8926d

File tree

7 files changed

+23
-7
lines changed

7 files changed

+23
-7
lines changed

.idea/codeStyles/codeStyleConfig.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/laravel-addressing.iml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Support/Validation/Rules/AdministrativeAreaCodeRule.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Contracts\Validation\Rule;
66
use Galahad\LaravelAddressing\Entity\Country;
7+
use Throwable;
78

89
class AdministrativeAreaCodeRule implements Rule
910
{
@@ -27,7 +28,9 @@ public function __construct(Country $country)
2728
*/
2829
public function passes($attribute, $value) : bool
2930
{
30-
if (! is_string($value)) {
31+
try {
32+
$value = (string) $value;
33+
} catch (Throwable $exception) {
3134
return false;
3235
}
3336

src/Support/Validation/Rules/AdministrativeAreaNameRule.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Contracts\Validation\Rule;
66
use Galahad\LaravelAddressing\Entity\Country;
7+
use Throwable;
78

89
class AdministrativeAreaNameRule implements Rule
910
{
@@ -27,7 +28,9 @@ public function __construct(Country $country)
2728
*/
2829
public function passes($attribute, $value) : bool
2930
{
30-
if (! is_string($value)) {
31+
try {
32+
$value = (string) $value;
33+
} catch (Throwable $exception) {
3134
return false;
3235
}
3336

src/Support/Validation/Rules/CountryCodeRule.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Contracts\Validation\Rule;
66
use Galahad\LaravelAddressing\LaravelAddressing;
7+
use Throwable;
78

89
class CountryCodeRule implements Rule
910
{
@@ -27,7 +28,9 @@ public function __construct(LaravelAddressing $addressing)
2728
*/
2829
public function passes($attribute, $value) : bool
2930
{
30-
if (! is_string($value)) {
31+
try {
32+
$value = (string) $value;
33+
} catch (Throwable $exception) {
3134
return false;
3235
}
3336

src/Support/Validation/Rules/CountryNameRule.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Contracts\Validation\Rule;
66
use Galahad\LaravelAddressing\LaravelAddressing;
7+
use Throwable;
78

89
class CountryNameRule implements Rule
910
{
@@ -27,7 +28,9 @@ public function __construct(LaravelAddressing $addressing)
2728
*/
2829
public function passes($attribute, $value) : bool
2930
{
30-
if (! is_string($value)) {
31+
try {
32+
$value = (string) $value;
33+
} catch (Throwable $exception) {
3134
return false;
3235
}
3336

src/Support/Validation/Rules/PostalCodeRule.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Galahad\LaravelAddressing\Entity\Country;
77
use Galahad\LaravelAddressing\Entity\Subdivision;
88
use CommerceGuys\Addressing\Subdivision\PatternType;
9+
use Throwable;
910

1011
class PostalCodeRule implements Rule
1112
{
@@ -36,7 +37,9 @@ public function __construct(Country $country, Subdivision $administrative_area =
3637
*/
3738
public function passes($attribute, $value) : bool
3839
{
39-
if (! is_string($value)) {
40+
try {
41+
$value = (string) $value;
42+
} catch (Throwable $exception) {
4043
return false;
4144
}
4245

0 commit comments

Comments
 (0)