Skip to content

Conversation

johnnylambada
Copy link

Validate Custom

Adding validateCustom, you can set a public static function do validation, for example:

<EditText
  android:id="@+id/password"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  app:validateCustom='@{"br.com.ilhasoft.support.validation.sample.MainActivity.validatePassword"}'
  app:validateCustomMessage="@{@string/custom_error_password_description}"
  />

// in MainActivity:
public static boolean validatePassword(String password){
    return password.matches(".*[a-z].*") &&
           password.matches(".*[A-Z].*") &&
           password.matches(".*[0-9].*");
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant