This repository has been archived by the owner on Apr 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Configure
Tomáš Mlynarič edited this page May 30, 2018
·
7 revisions
If you want to use different error resources than defaults or even that you want to validate known fields differently, there are many options, how to configure ValiFi.
Library provides simple configuration in your application class.
public class MyApplication extends Application {
@Override
public void onCreate() {
ValiFi.install(this,
new ValiFi.Builder()
.setErrorResource(ValiFi.Builder.ERROR_RES_EMAIL, R.string.my_custom_email_error)
.setPattern(ValiFi.Builder.PATTERN_EMAIL, Patterns.EMAIL_ADDRESS)
.setErrorDelay(1000)
.build()
);
}
}
You may set error resource or patterns for field types. All of these parameters are applied for all fields in whole application.
Available error resources:
ERROR_RES_NOT_EMPTY
ERROR_RES_LENGTH_MIN
ERROR_RES_LENGTH_MAX
ERROR_RES_LENGTH_RANGE
ERROR_RES_LENGTH_EXACT
ERROR_RES_EMAIL
ERROR_RES_PHONE
ERROR_RES_USERNAME
ERROR_RES_PASSWORD
ERROR_RES_YEARS_OLDER_THAN
Available patterns:
PATTERN_EMAIL
PATTERN_PHONE
PATTERN_PASSWORD
PATTERN_USERNAME