Lemon-Framework / Lemon

🍋 A php microframework
https://lemon-framework.github.io/docs/
GNU General Public License v3.0
24 stars 8 forks source link

[Validation] Fallback values #119

Closed tenmajkl closed 1 year ago

tenmajkl commented 1 year ago

This PR improves validaton in Request. From now on, Request::validate() won't return bool, but suspend your route callback with given value.

Meaning that instead of

$ok = $request->validate([
    'foo' => 'numeric',
]);

if (!$ok) {
    return 'error';
}

you can do just

$request->validate([
    'foo' => 'numeric',
], 'error');