Skip to content
This repository was archived by the owner on Nov 5, 2025. It is now read-only.

Custom validation with new validateCustom tag#21

Open
johnnylambada wants to merge 2 commits intoIlhasoft:masterfrom
johnnylambada:feature/validateCustom
Open

Custom validation with new validateCustom tag#21
johnnylambada wants to merge 2 commits intoIlhasoft:masterfrom
johnnylambada:feature/validateCustom

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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant