Skip to content
This repository has been archived by the owner on Apr 24, 2023. It is now read-only.
Tomáš Mlynarič edited this page Jan 20, 2018 · 3 revisions

Forms for validating multiple fields

// init of fields
public final ValiFieldEmail email = new ValiFieldEmail();
public final ValiFieldUsername username = new ValiFieldUsername();
...
public final ValiFiForm form = new ValiFiForm(email, username, password, password2, phone);

And then instead of checking fields, just check form

<Button
	android:enabled="@{viewModel.form.valid}"
	android:text="Submit" />

This will ensure that all of specified fields must be valid in order to enable the submit button.

Destroying is easy

@Override
void onDestroy(){
  form.destroy();
  super.onDestroy();
}
Clone this wiki locally