Added paradigm for UseCase input validation. #15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello,
I hope this message finds you well and enjoying your weekend. I am a backend developer from South Korea who has been studying Hexagonal Architecture and gaining various insights through your Modular-Architecture-Hexagonal-Demo-Project.
While studying your source code, I pondered on the part about input validation. Since the UseCaseHandler is called through the publisher, it seems we have to do input validation twice: once at the REST level, and then again at the UseCaseHandler level.
I found this situation to be quite inefficient. Consequently, I thought of creating an isSatisfied method in the UseCase interface, which is invoked within the Publisher method prior to calling the handle method of UseCaseHandler. This approach seems to streamline the process of validating input values, avoiding unnecessary repetitions.
With this approach, the following benefits were observed:
We can directly bind from the API to the UseCase.
We can achieve unified domain UseCase input validation.
We can focus the business logic in UseCaseHandler.
I have applied these thoughts in code and am submitting them in this Pull Request. As I am not very experienced, I may not have considered all perspectives. Even if this does not contribute directly, I would very much appreciate your candid feedback.