⚠️ Malware / Trojaner / VirenBe alert: targeted attacks on prominent Rustaceans(17.09.2026 um 02:00 Uhr)
🔧 ProgrammierungWINDOW FUNCTIONS(17.09.2026 um 19:50 Uhr)
🔧 Programmierung🚀 bro.js v2.4.5 – Next.js Adapter & AI‑First DX(17.09.2026 um 19:58 Uhr)
🔧 ProgrammierungRDS vs DynamoDB: How I Think About Choosing an AWS Database(17.09.2026 um 20:00 Uhr)
⚠️ Malware / Trojaner / VirenBe alert: targeted attacks on prominent Rustaceans(17.09.2026 um 02:00 Uhr)
🔧 ProgrammierungWINDOW FUNCTIONS(17.09.2026 um 19:50 Uhr)
🔧 Programmierung🚀 bro.js v2.4.5 – Next.js Adapter & AI‑First DX(17.09.2026 um 19:58 Uhr)
🔧 ProgrammierungRDS vs DynamoDB: How I Think About Choosing an AWS Database(17.09.2026 um 20:00 Uhr)
🔧 Programmierung 🕛 vor 2 Monaten 8 Min Lesezeit
0

Laravel Precognition: Live Validation That Reuses Your Backend Rules

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht


  • Book: + | | removes the second copy. The front end asks the server "would this pass?" before the user submits, and the server answers using the exact same validation rules the real request will run.






    What a precognitive request actually is



    A precognitive request is a normal HTTP request to your real endpoint, tagged with a Precognition: true header. Laravel sees the header, runs the route's middleware and validation, and then stops before your controller does any real work. It never writes a row. It never sends an email. It runs the rules and returns the verdict.



    Success comes back as 204 No Content with a Precognition-Success: true header. Failure comes back as a normal 422 with the same JSON error bag your form submit would produce. Same rules, same messages, same field names. There is no second schema to drift.



    The lifecycle is worth holding in your head:




    1. Front end sends the form state to the real URL with Precognition: true.

    2. Middleware runs. FormRequest validation runs.

    3. Laravel short-circuits: your controller body never executes.

    4. Response is 204 (valid) or 422 (invalid).



    The controller is skipped by design. That is what makes it safe to fire on every keystroke.






    Wiring the backend



    You need two things: the middleware on the route, and a form request that already holds your rules. If you have the form request, you are most of the way there.




    CODE
    use App\Http\Requests\StoreUserRequest;
    use Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests;

    Route::post('/users', [UserController::class, 'store'])
    ->middleware(HandlePrecognitiveRequests::class);






    The form request is unchanged. This is the same class your real POST already validates against:




    CODE
    <?php

    namespace App\Http\Requests;

    use Illuminate\Foundation\Http\FormRequest;
    use Illuminate\Validation\Rules\Password;

    class StoreUserRequest extends FormRequest
    {
    public function rules(): array
    {
    return [
    'name' => ['required', 'string', 'max:120'],
    'email' => ['required', 'email', 'max:255'],
    'password' => [
    'required',
    'confirmed',
    Password::min(12)->mixedCase()->numbers(),
    ],
    ];
    }
    }






    One ruleset. The submit path uses it. The live-check path uses it. When you raise the password minimum, both paths move together because there is only one place to edit.






    The live check on the front end



    Laravel ships a small client per framework: , and



    Available on Kindle, Paperback, and Hardcover. English, German, and Japanese editions out now — Portuguese and Spanish coming soon.

    Vollständiger Original-Artikel
    Den kompletten Beitrag mit allen Details direkt auf dev.to lesen.
    ↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
Sennheiser Momentum True Wireless 5 earbuds review: Next-gen in every way
1 Quelle
Cyberattacks on Oil Tankers Put Maritime Critical Infrastructure at Risk
1 Quelle
OpenAI veröffentlicht neue KI-Zwischenfälle mit Schummelei und Hackerangriffen
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Laravel Precognition: Live Validation That Reuses Your Backend Rules

Thematisch verwandte Begriffe: Laravel, Precognition, Live, Validation · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...