Skip to content

Instantly share code, notes, and snippets.

@jakubkinst
Last active March 7, 2018 08:39
Show Gist options
  • Save jakubkinst/b09ad19c6524f15af2df3647bd014097 to your computer and use it in GitHub Desktop.
Save jakubkinst/b09ad19c6524f15af2df3647bd014097 to your computer and use it in GitHub Desktop.
val email = mutableLiveDataOf(defaultEmail)
val password = mutableLiveDataOf(defaultPassword)
val formValid = MediatorLiveData<Boolean>().apply {
addSource(email, {value = validateForm(email.value, password.value)})
addSource(password, {value = validateForm(email.value, password.value)})
}
private fun validateForm(email: String, password: String): Boolean
= validateEmail(email) && validatePassword(password, config.MIN_PASSWORD_LENGTH)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment