Spaces:
Running
Running
File size: 425 Bytes
b2dcf0f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <?php
namespace App\Shared\Validation;
use App\Shared\Exceptions\ApiException;
class OwnershipValidator
{
public function ensureOwner(?string $actualOwnerId, string $expectedOwnerId, string $message = 'The record is not available.'): void
{
if ($actualOwnerId === null || $actualOwnerId !== $expectedOwnerId) {
throw new ApiException('RESOURCE_NOT_FOUND', $message, [], 404);
}
}
}
|