diff --git a/src/Models/Address.php b/src/Models/Address.php index 2bc0b88..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 (!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 2cc777e..0365c6c 100644 --- a/src/config/addresses.php +++ b/src/config/addresses.php @@ -1,6 +1,10 @@ [ + 'uk-postcode' => true, + 'country-code' => true, + ], 'geocoding' => [ 'enabled' => true, 'google-maps' => [