-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Signup.pug not displaying Sequelize error (even with the fix) #2485
Comments
Hello Nate, i made the last change to fixe the sequelize error not displayed correctly. I dont know anything about pug, can you look for my changes to see if you can bring it for pug? I will take a look on my side. |
Nate, today i try to follow your steps to reproduce your issue. |
I mean i will try... when i have a chance :) |
Thanks! Seems as though the error I get back from Sequelize 4.0.0-2 are structured a little differently than expected. The angular.forEach seems to loop through a fields array. In my case, the fields property returned was just an object: But the .errors property has an array that seems to address my needs:
In signup.controller.js, I changed the catch to look like this:
and everything works OK now. I would submit a PR but I'm wondering if the structure of the error is unique to Sequelize 4.0.0-2 so perhaps not widely applicable? |
Maybe we can test error structure from sequelize and provide the right way
to loop throughout the errors
Le 3 févr. 2017 12:14 AM, "Nate Stuyvesant" <[email protected]> a
écrit :
… Thanks! Seems as though the error I get back from Sequelize 4.0.0-2 are
structured a little differently than expected. The angular.forEach seems to
loop through a fields array. In my case, the fields property returned was
just an object:
fields: { email: ***@***.***' }
But the .errors property has an array that seems to address my needs:
errors:
[ ValidationErrorItem {
message: 'A user with that email address already exists.',
type: 'unique violation',
path: 'email',
value: ***@***.***' } ]
In signup.controller.js, I changed the catch to look like this:
.catch(err => {
err = err.data;
this.errors = {}; // reset to only the latest errors
// Update validity of form fields that match the sequelize errors
if(err.name) {
for(let error of err.errors) { // leverage ES6's for/of instead of angular.forEach
form[error.path].$setValidity('sequelize', false);
this.errors[error.path] = error.message;
}
}
});
and everything works OK now. I would submit a PR but I'm wondering if the
structure of the error is unique to Sequelize 4.0.0-2 so perhaps not widely
applicable?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2485 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AF19cdchf6_JlpUmKXagEGM-joRBVxRYks5rYrepgaJpZM4L0swr>
.
|
Hello Nate, |
Still digging into the resolution but noticed that the generated signup.pug is setup to handle Mongoose errors but has some issues with displaying the error from Sequelize.
To see what I'm talking about,
What you'll see is that the email address field is correctly highlighted but the error passed back from server/api/user/user.controller.js:create isn't displayed in vm.errors.email in signup.pug. Also, the input attribute "mongoose-error" should probably be called "sequelize-error" if filters.sequelizeModels.
Here's the error output:
Saw that there was a fix for this but it didn't work for me.
Thanks,
Nate
The text was updated successfully, but these errors were encountered: