Language

SaveInfo.Builder.SetValidator(IValidator) メソッド

定義

ユーザー入力の検証に使用するオブジェクトを設定します。入力が無効な場合、オートフィル保存 UI は表示されません。

[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

パラメーター

validator
IValidator

Android システムによって提供される実装。 この値は null にすることはできません。

返品

このビルダー。 この値は null にすることはできません。

属性

注釈

ユーザー入力の検証に使用するオブジェクトを設定します。入力が無効な場合、オートフィル保存 UI は表示されません。

通常、クレジット カード番号を検証するために使用されます。

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.service.autofill.SaveInfo.Builder.setValidatorの Android リファレンス。

このページの一部は、によって作成および共有され、に記載されている条件に従って使用される作業に基づく変更です。

適用対象