-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Return resource.errors.full_messages in addition to resource.errors #44
Comments
I think the current error-handling system is mostly haphazard. I've been wanting to formalize the errors, but I keep getting distracted. I'll make this a priority for the next release. I do have some ideas on this, I'll post back to this issue ASAP. |
I'm willing to help in whatever way makes sense. Let me know if you think any of that work is delegable to me. |
Sorry for the delay. I think the best way to handle this will be to return the full error object, including Just to be clear:
The For example: <fieldset ng-class="{error: errors.full_messages.length}">
<div>
<label>Email</label>
<p class="errors" ng-show="errors.messages['email']">Email {{ errors.messages['email'] }}</p>
<input type="text" name="email" ng-model="form.email" />
</div>
</fieldset> The So I think it's probably best to standardize all the errors so that they look like this: {
data: {
errors: {
messages: {
// messages hash contents
},
full_messages: [
// full_messages array contents
]
}
}
} Do you agree? Is this something that you would like to take on? |
Totally agree, and yes. Is there any certain process I should be following? Create a branch, implement the feature, issue pull request? |
I would prefer this process:
You can run the test suite using the following steps:
This will open the guard test-runner. Guard will re-run each test suite when changes are made to its corresponding files. I should probably add a CONTRIBUTING.md or something :) |
Okay, I'm with you. I was including steps 2 and 3 in "implement the feature", I just didn't explicitly say it. And I already cloned your repo and ran your tests a long time ago. :) I'm actually on vacation right now but let me take a closer look at this later in the week and give you a rough feel for timeline. Thanks for the opportunity to help. |
I checked my schedule: I can get this in place by the end of next week (the week ending 10/24). |
Awesome, thanks @jasonswett! Let me know if you run into any trouble. |
Hmm, after getting into the implementation a little bit I'm realizing that splitting
into
might carry some unwanted baggage. The issues to me are:
What would you think about this structure instead?
|
@jasonswett - I agree! Good work 👍 |
Okay, the change is in place. I'm new to open source contribution so I don't know if I did all the steps right. Here's a link to my pull request: #50 |
Cool, thanks @jasonswett! I'll review ASAP. |
Merged! Check out:
Please test and confirm that everything works! |
Will do. Thanks! |
@jasonswett - you may want to hold off testing until I fix a bug that was introduced regarding #51. I'll let you know when everything has stabilized. |
10-4 |
Ok @jasonswett - the problem should be fixed in |
@jasonswett - this seems to be working ok. I'm closing this, but please re-open if you find any issues. Thanks again for the PR 😺 |
@lynndylanhurley You're welcome for the PR! Sorry for my slowness here - been a bit underwater lately. |
In
RegistrationsController#create
, might it be a good idea to returnresource.errors.full_messages
instead ofresource.errors
? Thefull_messages
version seems to me to be easier to consume on the client side.One reservation I do have is that maybe
devise_token_auth
isn't always used in client-server-architected apps. "Traditional" apps would of course still probably wantresource.errors
as opposed toresource.errors.full_messages
. So if we were to make a change, we would probably only want to make it for JSON requests.I forked the project and changed
resource.errors
toresource.errors.full_messages
and it works well for me.What do you think?
The text was updated successfully, but these errors were encountered: