Integrations · Updated 2026-10-20

Signup checks in Laravel

A Laravel validation rule that rejects throwaway and fake signups using the HTTP client, with a fail-open timeout.

Configure the key

// config/services.php
'veqen' => [
    'key' => env('VEQEN_API_KEY'),
],

A validation rule

<?php
// app/Rules/RealSignup.php
namespace App\Rules;

use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Support\Facades\Http;

class RealSignup implements ValidationRule
{
    public function __construct(private ?string $ip = null) {}

    public function validate(string $attribute, mixed $value, Closure $fail): void
    {
        try {
            $response = Http::withToken(config('services.veqen.key'))
                ->timeout(4)
                ->post('https://veqen-app.com/v1/signup/check', ['email' => $value, 'ip' => $this->ip]);
        } catch (\Throwable) {
            return; // fail open
        }
        if (! $response->successful()) {
            return;
        }
        if ($suggestion = $response->json('email.did_you_mean')) {
            $fail("Did you mean {$suggestion}?");
        } elseif ($response->json('risk.verdict') === 'refuse') {
            $fail('Please use a permanent email address.');
        }
    }
}

Use it

use App\Rules\RealSignup;

$request->validate([
    'email' => ['required', 'email', new RealSignup($request->ip())],
    'password' => ['required', 'min:10'],
]);

$request->ip() returns the visitor's address when Laravel's TrustProxies middleware is configured for your load balancer.