Thread
#compose
    Colton Idle

    Colton Idle

    1 year ago
    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 Composable2️⃣ the validation/restriction of chars is built into your "ViewModel"
    pepos

    pepos

    1 year ago
    I prefer to test this logic in a JVM test instead of an UI Android test -> ViewModel
    the less thing you need to test during an Android UI test the better
    Zhelyazko Atanasov

    Zhelyazko Atanasov

    1 year ago
    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
    Sean McQuillan [G]

    Sean McQuillan [G]

    1 year ago
    3. Validation done by a Validator class that's hoisted appropriately (such as the ViewModel)