City-of-Bloomington / blossom

A skeleton for PHP web applications
GNU Affero General Public License v3.0
3 stars 0 forks source link

Improve validation and error messaging #11

Open inghamn opened 9 years ago

inghamn commented 9 years ago

what are the possible errors? What was the field? Defer the message text to the view Validation should throw a single exception

$errors = [
    'fieldname' => [
        'errorType1', 'errorType2', 'errorType3
    ],
    'otherField' => [
        'otherFielderror', 'otherFieldProblem'
    ]
];

Model should define the validation fields and possible errors. Model should implement the validation check

Controller tries to save, catches the exception, Passes the exception to the SESSION, and lets the form render

Model save triggers validation

$_SESSION['messages']['validation'] = $errors;