Example of Custom validation rules in spatie/spatie.be

File app/Rules/MatchingLicense.php (link to Github)
use App\Models\Activation;
use App\Models\License;
use Illuminate\Contracts\Validation\Rule;

class MatchingLicense implements Rule
{
    public function passes($attribute, $licenseKey)
    {
        if (! $license = License::firstWhere('key', $licenseKey)) {
            return false;
        }

        return $license->activations()->where('id', $this->activation->id)->exists();
    }
}
File app/Http/Api/Requests/Activations/ShowActivationRequest.php (link to Github)
use App\Rules\MatchingLicense;
use Illuminate\Foundation\Http\FormRequest;

class ShowActivationRequest extends FormRequest
{
    public function rules()
    {
        return [
            'license_key' => ['required', new MatchingLicense($this->activation)],
        ];
    }
}
File resources/views/components/field.blade.php (link to Github)
<div class="grid row-gap-2">
    {{ $slot }}
</div>

Additional resources on custom validation rules: