diff --git a/src/Models/Address.php b/src/Models/Address.php index 0f4dc72..ee00c1a 100644 --- a/src/Models/Address.php +++ b/src/Models/Address.php @@ -73,13 +73,13 @@ public function getHumanReadableAttribute(): string public function validate(): void { - if (!$this->country) { + if (config('addresses.validation.country-code') && !$this->country) { throw new InvalidCountryException(); } switch ($this->country->isoCodeAlpha3) { case 'GBR': - if (config('addresses.gbr-validation.enabled') && !Validator::validatePostcode($this->postcode)) { + if (config('addresses.validation.uk-postcode') && !Validator::validatePostcode($this->postcode)) { throw new InvalidUKPostcodeException(); } break; diff --git a/src/config/addresses.php b/src/config/addresses.php index baeef75..0365c6c 100644 --- a/src/config/addresses.php +++ b/src/config/addresses.php @@ -1,8 +1,9 @@ [ - 'enabled' => true + 'validation' => [ + 'uk-postcode' => true, + 'country-code' => true, ], 'geocoding' => [ 'enabled' => true,