-
-
Notifications
You must be signed in to change notification settings - Fork 127
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
Added feature to share individual input validation errors in session #553
Added feature to share individual input validation errors in session #553
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, this would be better to do it in its own middleware to allow a user to disable sharing validation errors.
Also errors are already shared in session through errors
key. I would directly use this key instead of using validation_errors
key.
So maybe, we should mix both of those approach in ShareErrorsInSession
middleware:
- Put sharing errors logic in this middleware
- Map errors with MessageBag as you did.
We would end up with something like this:
class ShareErrorsInSessionMiddleware(Middleware):
def before(self, request, response):
request.app.make("view").share(
{
"errors": MessageBag(Session.pull("errors") or {}),
}
)
return request
def after(self, request, _):
return request
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created separate middleware to handle errors in frontend...
src/masonite/middleware/route/ShareErrorsInSessionMiddleware.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed requested changes.
I took a look again here and I would like to add a unit test. |
whats going on with this PR? is it good? |
Hmm for now there is something with the unit test I wrote, I don't know if the issue is coming from tests or from the framework itself. I will push this so we can discuss it. |
@josephmancuso @girardinsamuel what's the status for this PR? Any issues? It's working perfectly in my case in all of my applications. |
I was waiting for the last release to be made, to hopefully fix the unit tests I pushed to this PR. |
…nite into yubarajshrestha-feature/552
Put this forked branch up to date with 4.0 |
@yubarajshrestha what's preventing me from merging it really is that failing test. |
It's a test I have added. I will remove it for now |
17eddc6
to
8a875c3
Compare
8a875c3
to
65fa5a1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's okay for me for now.
In Masonite 5, maybe we will need to refactor session flashing and message bag validation features.
Fixes #552.