Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve validation and error messaging #11

Open
inghamn opened this issue Jun 14, 2015 · 0 comments
Open

Improve validation and error messaging #11

inghamn opened this issue Jun 14, 2015 · 0 comments

Comments

@inghamn
Copy link
Member

inghamn commented Jun 14, 2015

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

  • Custom validation exception with errors added
  • Errors in known data structure
$errors = [
    'fieldname' => [
        'errorType1', 'errorType2', 'errorType3
    ],
    'otherField' => [
        'otherFielderror', 'otherFieldProblem'
    ]
];

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

  • Throw the exception
  • Pack all the errors into the exception

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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant