Skip to content
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

Validation Logic #8

Closed
aklscv opened this issue May 5, 2020 · 2 comments
Closed

Validation Logic #8

aklscv opened this issue May 5, 2020 · 2 comments

Comments

@aklscv
Copy link

aklscv commented May 5, 2020

How would you share the validation logic between the Create and Update methods on the CustomerController if you needed to check for name, email and email validation uniqueness on both methods? Would a private method be sufficient? What if that logic needed to be shared somewhere else?

@vkhorikov
Copy link
Owner

If it's just 2 places (create and update), I usually don't bother to gather this logic into a single spot, just duplicate the uniqueness validation. If becomes needed somewhere else -- look at why. If it's a totally unrelated API endpoint, then duplicate it there too. If it's something related to customer creation/update, then add a domain service and move that logic there (though most likely, you'd need to move more than just uniqueness validation).

@aklscv
Copy link
Author

aklscv commented May 6, 2020

Thank you for your insight!

@aklscv aklscv closed this as completed May 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants