[Improvement] Extract email validation for common usage
hoangnguyen92dn opened this issue · comments
Issue
There is the same logic to validate an email in ForgotViewModel
and LoginViewModel
so I'd suggest extracting this to a function for common usage.
Expected
The email validation function will be created and invoked in the ViewModel classes.
This is fixed in PR #22
@thiennguyen0196 For this issue, I am not sure about your idea by using Inline class
rather than extension 🤔 Can you please explain in detail why you would go with the current approach instead?
@hoangnguyen92dn
Indeed using extension was my first thought to extract the common usage function. However, in this case, I also want to distinguish between email text and password text so they cannot be passed wrongly in the arguments of viewModel.submitLogin()
function. For example, if they are still string type, there is a chance that we could pass password text for email field and vice versa.
To sum up, I use inline class to have more strict usage in passing arguments with viewModel.submitLogin()
function 😄
Got your idea now. Thanks for your explanation 👍