SaveInfo.Builder.SetValidator(IValidator) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Sets an object used to validate the user input - if the input is not valid, the autofill save UI is not shown.
[Android.Runtime.Register("setValidator", "(Landroid/service/autofill/Validator;)Landroid/service/autofill/SaveInfo$Builder;", "", ApiSince=27)]
public Android.Service.Autofill.SaveInfo.Builder SetValidator(Android.Service.Autofill.IValidator validator);
[<Android.Runtime.Register("setValidator", "(Landroid/service/autofill/Validator;)Landroid/service/autofill/SaveInfo$Builder;", "", ApiSince=27)>]
member this.SetValidator : Android.Service.Autofill.IValidator -> Android.Service.Autofill.SaveInfo.Builder
Parameters
- validator
- IValidator
an implementation provided by the Android System. This value cannot be null.
Returns
this builder. This value cannot be null.
- Attributes
Remarks
Sets an object used to validate the user input - if the input is not valid, the autofill save UI is not shown.
Typically used to validate credit card numbers.
Validator validator = new RegexValidator(ccNumberId, Pattern.compile(""^\\d{16}$"))
import static android.service.autofill.Validators.and;
import static android.service.autofill.Validators.or;
Validator validator =
and(
new LuhnChecksumValidator(ccNumberId),
or(
new RegexValidator(ccNumberId, Pattern.compile("^\\d{16}$")),
new RegexValidator(ccNumberId, Pattern.compile("^108\\d{12}$"))
)
);
Validator validator =
and(
new LuhnChecksumValidator(ccNumberId),
new RegexValidator(ccNumberId, Pattern.compile(""^(\\d{16}|108\\d{12})$"))
);
import static android.service.autofill.Validators.and;
Validator validator =
and(
new RegexValidator(ccNumberId1, Pattern.compile("^\\d{4}$")),
new RegexValidator(ccNumberId2, Pattern.compile("^\\d{4}$")),
new RegexValidator(ccNumberId3, Pattern.compile("^\\d{4}$")),
new RegexValidator(ccNumberId4, Pattern.compile("^\\d{4}$"))
);
Android reference for android.service.autofill.SaveInfo.Builder.setValidator.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.