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] error messages #124

Closed tenmajkl closed 1 year ago

tenmajkl commented 1 year ago

This PR adds error messages to validation, meaning that now, when validation error ocures, instead of just saying "Bad data" you get better errors. So if we pass request

foo=bar

into this validation

$r->validate([
    'foo' => 'numeric',
], template('foo'));

with this template

{ ifError }
    <div class="error">
        { error }
    </div>
{ /ifError }

response would be div with class error and message Value foo must be numeric.

All the error messages are from translations.

Resolves #112