Skip to content

Commit 66a9141

Browse files
committed
Update VatDetailsFromVatID.php
1 parent 5c05aca commit 66a9141

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/Services/VatDetailsFromVatID.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
namespace TantHammar\LaravelRules\Services;
44

5+
use TantHammar\LaravelRules\Enums\BusinessNameLookupError;
6+
use TantHammar\LaravelRules\Rules\VatNumberFormat;
7+
58
/**
69
* eu format or uk format:<br>
710
*
@@ -25,6 +28,11 @@ public static function lookup(string $vatID): object
2528
return $empty;
2629
}
2730

31+
//do simple validation before calling external api
32+
if (! (new VatNumberFormat)->passes(null, $vatID)) {
33+
return $empty;
34+
}
35+
2836
// Do not use Facade. Configure VatCalculator to throw an error when country != GB, else only bool false is returned
2937
$calculator = new \Mpociot\VatCalculator\VatCalculator(['forward_soap_faults' => true]);
3038
try {

0 commit comments

Comments
 (0)