Skip to content

Commit

Permalink
Merge pull request #7 from SteJaySulli/feature/config-uk-postcodes
Browse files Browse the repository at this point in the history
Feature/config uk postcodes
  • Loading branch information
DivineOmega authored Oct 13, 2020
2 parents 8a404aa + f0115e1 commit 2763012
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Models/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/config/addresses.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php

return [
'validation' => [
'uk-postcode' => true,
'country-code' => true,
],
'geocoding' => [
'enabled' => true,
'google-maps' => [
Expand Down

0 comments on commit 2763012

Please sign in to comment.