-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the middleware without adding it to the container (#12)
- Loading branch information
1 parent
b44f94d
commit 38f5c92
Showing
3 changed files
with
366 additions
and
229 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
38f5c92
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.
Any reason for not using the container anymore? It looked like a cleaner solution to me.
38f5c92
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.
Because you have to create n container keys for your n routes and every route has its special key to call
hasErrors
method. From my point of view this is not modular at all.38f5c92
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.
I see. Makes sense.
Is using the container still an option in the latest version? I have an older project using this method (for only 2 routes, so 2 keys) and I don't really want to break it by updating if I don't have to.
38f5c92
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.
Yes, it's an option, but you have to change something to make it works. You can still use the container to add the validator to a route, but you have to change the way you call
hasErrors
andgetErrors
methods.E.g.:
I have not tested it, but it should work. 😸