Lets say I have a Composable that represents an input field and this input field has some sort of restriction in what it can take in.
It could be
@Composeable fun MyEmailInputField() { ... }
@Composeable fun MyPhoneInputField() { ... }
@Composeable fun MyPasswordInputField() { ... }
Would you have:
1️⃣ the validation/restriction of chars is built into the Composable
2️⃣ the validation/restriction of chars is built into your "ViewModel"
1️⃣ 5
2️⃣ 15
p
pepos
06/11/2021, 2:27 AM
I prefer to test this logic in a JVM test instead of an UI Android test -> ViewModel
pepos
06/11/2021, 2:27 AM
the less thing you need to test during an Android UI test the better
z
Zhelyazko Atanasov
06/11/2021, 6:07 AM
If I have to use the same validation in multiple places, I would go further and put the validation in another class / function - e.g. an Interactor / UseCase maybe. Then have the ViewModel call this class / function
➕ 3
s
Sean McQuillan [G]
06/16/2021, 2:15 PM
3. Validation done by a Validator class that's hoisted appropriately (such as the ViewModel)